python/ sqlite
I am learning sqlite3 in python3. I have added 4 columns in my table using the syntax
c.execute("CREATE table raman(ATOMIC NUMBER INT, SYMBOL TEXT, ROW INT , COLUMN INT)")
and I want to insert values for them so I am writing
c.execute("INSERT INTO raman VALUES(1,'H',1,'1')");
After this if I print the table its not showing me the inserted values. I am using this command to print print c.execute("SELECT * FROM SQLITE_ master type='table'").fetchall()
The complete (minimal) sequence is this.
>>> conn = sqlite3.connect(':memory:')
>>> c = conn.cursor()
>>> c.execute("CREATE table raman(ATOMIC NUMBER INT, SYMBOL TEXT, ROW INT , COLUMN INT)")
<sqlite3.Cursor object at 0x000000000296E490>
>>> c.execute("INSERT INTO raman VALUES(1,'H',1,'1')");
<sqlite3.Cursor object at 0x000000000296E490>
>>> conn.commit()
>>> for row in c.execute('SELECT * FROM raman'):
... row
...
(1, 'H', 1, 1)
Until you issue the commit
the values won't be (or won't necessarily be) present in the table.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.