from pysqlite2 import dbapi2 as sqlite3 conn sqlite3 connect tmp test

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
>>> from pysqlite2 import dbapi2 as sqlite3
>>> conn = sqlite3.connect('/tmp/test.db')
>>> conn.isolation_level = None
cur = conn.cursor()
cur.execute("""create table students (name text, family text, ngroup text)""")
cur.execute("""insert into students values('bla', 'Bla', 'M35071')""")
cur.execute("""insert into students values('Bla2', 'Bla2', 'M35052')""")
>>> >>> >>> <pysqlite2.dbapi2.Cursor object at 0x2aaaaab33920>
>>> <pysqlite2.dbapi2.Cursor object at 0x2aaaaab33920>
>>> <pysqlite2.dbapi2.Cursor object at 0x2aaaaab33920>
>>> cur.execute("""select * from students""")
for row in cur:
print row
<pysqlite2.dbapi2.Cursor object at 0x2aaaaab33920>
>>> >>> ... ...
(u'bla', u'Bla', u'M35071')
(u'Bla2', u'Bla2', u'M35052')
>>> conn.close()
Other process:
akhavr@devel ~/src/chytach $ python
Python 2.4.4 (#1, May 15 2007, 20:42:45)
[GCC 4.1.1 20070105 (ALT Linux, build 4.1.1-alt11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pysqlite2 import dbapi2 as sqlite3
>>> conn = sqlite3.connect('/tmp/test.db')
File "<stdin>", line 1
conn = sqlite3.connect('/tmp/test.db')
^
SyntaxError: invalid syntax
>>> conn = sqlite3.connect('/tmp/test.db')
>>> cur = conn.cursor()
>>> cur.execute('select * from students')
<pysqlite2.dbapi2.Cursor object at 0x2aaaaab338c8>
>>> for row in cur: print row
...
(u'bla', u'Bla', u'M35071')
(u'Bla2', u'Bla2', u'M35052')