Last active
March 18, 2016 23:28
-
-
Save brianv0/9ef54bda9530e41dcb20 to your computer and use it in GitHub Desktop.
pysqlite with sqlite3_column_type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12) | |
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> from pysqlite2 import dbapi2 as sqlite3 | |
>>> | |
>>> | |
>>> conn = sqlite3.connect() | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
TypeError: Required argument 'database' (pos 1) not found | |
>>> conn = sqlite3.connect("fake.db") | |
>>> | |
>>> curs = conn.cursor() | |
>>> curs.execute("CREATE TABLE Point (x INTEGER, y INTEGER)") | |
<pysqlite2.dbapi2.Cursor object at 0x1004ad4a8> | |
>>> | |
>>> | |
>>> curs.execute("SELECT * FROM POINT") | |
<pysqlite2.dbapi2.Cursor object at 0x1004ad4a8> | |
>>> curs.description() | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
TypeError: 'tuple' object is not callable | |
>>> curs.description | |
(('x', 5, None, None, None, None, None), ('y', 5, None, None, None, None, None)) | |
>>> curs.execute("INSERT INTO POINT (x,y) VALUES (1,2)") | |
<pysqlite2.dbapi2.Cursor object at 0x1004ad4a8> | |
>>> curs.execute("SELECT * FROM POINT") | |
<pysqlite2.dbapi2.Cursor object at 0x1004ad4a8> | |
>>> curs.description | |
(('x', 1, None, None, None, None, None), ('y', 1, None, None, None, None, None)) | |
>>> | |
>>> | |
>>> curs.execute("INSERT INTO POINT (x,y) VALUES ('x','y')") | |
<pysqlite2.dbapi2.Cursor object at 0x1004ad4a8> | |
>>> curs.execute("SELECT * FROM POINT") | |
<pysqlite2.dbapi2.Cursor object at 0x1004ad4a8> | |
>>> curs.description | |
(('x', 1, None, None, None, None, None), ('y', 1, None, None, None, None, None)) | |
>>> curs.fetchone() | |
(1, 2) | |
>>> curs.description | |
(('x', 1, None, None, None, None, None), ('y', 1, None, None, None, None, None)) | |
>>> curs.fetchone() | |
(u'x', u'y') | |
>>> curs.description | |
(('x', 1, None, None, None, None, None), ('y', 1, None, None, None, None, None)) | |
>>> conn.close() | |
>>> conn = sqlite3.connect("fake.db") | |
>>> curs = conn.cursor() | |
>>> curs.execute("SELECT * FROM POINT where x = 'x'") | |
<pysqlite2.dbapi2.Cursor object at 0x1004ad510> | |
>>> curs.description | |
(('x', 5, None, None, None, None, None), ('y', 5, None, None, None, None, None)) | |
>>> curs.fetchone() | |
>>> curs.description | |
(('x', 5, None, None, None, None, None), ('y', 5, None, None, None, None, None)) | |
>>> curs.execute("SELECT * FROM POINT") | |
<pysqlite2.dbapi2.Cursor object at 0x1004ad510> | |
>>> curs.description | |
(('x', 5, None, None, None, None, None), ('y', 5, None, None, None, None, None)) | |
>>> curs.fetchone() | |
>>> curs.description | |
(('x', 5, None, None, None, None, None), ('y', 5, None, None, None, None, None)) | |
>>> curs.execute("INSERT INTO POINT (x,y) VALUES (1,2)") | |
<pysqlite2.dbapi2.Cursor object at 0x1004ad510> | |
>>> curs.description | |
() | |
>>> curs.execute("SELECT * FROM POINT") | |
<pysqlite2.dbapi2.Cursor object at 0x1004ad510> | |
>>> curs.description | |
(('x', 1, None, None, None, None, None), ('y', 1, None, None, None, None, None)) | |
>>> curs.fetchone() | |
(1, 2) | |
>>> curs.fetchone() | |
>>> conn.commit() | |
>>> curs.execute("INSERT INTO POINT (x,y) VALUES ('x','y')") | |
<pysqlite2.dbapi2.Cursor object at 0x1004ad510> | |
>>> curs.execute("SELECT * FROM POINT") | |
<pysqlite2.dbapi2.Cursor object at 0x1004ad510> | |
>>> curs.fetchone() | |
(1, 2) | |
>>> curs.fetchone() | |
(u'x', u'y') | |
>>> curs.description | |
(('x', 1, None, None, None, None, None), ('y', 1, None, None, None, None, None)) | |
>>> curs.fetchone() | |
>>> | |
>>> conn.commit() | |
>>> curs.execute("DELETE FROM POINT WHERE x = 1") | |
<pysqlite2.dbapi2.Cursor object at 0x1004ad510> | |
>>> curs.description | |
() | |
>>> curs.execute("SELECT * FROM POINT") | |
<pysqlite2.dbapi2.Cursor object at 0x1004ad510> | |
>>> curs.fetchone() | |
(u'x', u'y') | |
>>> curs.description | |
(('x', 3, None, None, None, None, None), ('y', 3, None, None, None, None, None)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment