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.

Related Question Create two tables in sqlite3 database in Python Is it possible to create a python sqlite3 function to create generic tables Python sqlite3 create table syntax error Python using sqlite3 to create two tables with foreign keys? sqlite3 python generate tables Sqlite3 & Python creating tables joint two tables sqlite3 SQLite3 Unknown Error Programming error with SQlite3 Error with .output in sqlite3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM