im working through alan's sql tutorial. i have a few questions from there but 1st i wanted to try out an example in Core python's sql example.
>>> import sqlite3 >>> cxn = sqlite3.connect('sqlite_test/test') >>> cur = cxn.cursor() after this i created a table called users and inserted some data. then i did: >>> cur.execute('SELECT * from users') >>> for user in cur.fetchall(): print(user) i got the results of all data i gave the table. then did >>> cur.close() >>> cxn.commit() >>> cxn.close() i then closed this interactive IDLE session. i reopened another session and simply did >>> import sqlite3 >>> cxn = sqlite3.connect('sqlite_test/test') >>> cur = cxn.cursor() >>> for user in cur.fetchall(): print(user) >>> but this time no data was printed back to me, even though the database file 'test' already existed from the previous session. Why did this happen, cant i just connect and my data is still intact? or do i have to always re enter data from the previously saved session? My questions about http://www.alan-g.me.uk/tutor/tutdbms.htm is to open a database it uses the command line directly and doesnt creat cursor() or connect() objects e.g. E:\PROJECTS\SQL> sqlite3 employee.db sqlite> create table Employee ...> (EmpID,Name,HireDate,Grade,ManagerID); sqlite> insert into Employee (EmpID, Name, HireDate, Grade, ManagerID) ...> values ('1020304','John Brown','20030623','Foreman','1020311'); i tried this in my command line but got : python.exe: can't open file 'sqlite': [Errno 2] No such file or directory i tried creating the a folder called test and doing: test employee.db but no test.db was created. my main questions are it possible to use the command line without cursor() and connect() in python 3 or is it only for python 2. is it better from the command line or in a .py file. And also my previous question i had about having to re enter previously stored data _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor