Click here to Skip to main content
15,895,084 members

Comments by Member 14891535 (Top 29 by date)

Member 14891535 19-Jul-20 9:05am View    
Thanks. Do you have any idea how to check my connection is working? I presume is not related to MySQL
Member 14891535 19-Jul-20 8:44am View    
Can I know are you using ipython notebook to run your code?

Is it the exact code as I paste above?
Member 14891535 19-Jul-20 8:03am View    
Thanks. I had a look at the documentation provided, I presume is not related to MySQL


import sqlite3
conn = sqlite3.connect('example.db')

c = conn.cursor()

# Create table
c.execute('''CREATE TABLE stocks
(date text, trans text, symbol text, qty real, price real)''')

# Insert a row of data
c.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)")

# Save (commit) the changes
conn.commit()

# We can also close the connection if we are done with it.
# Just be sure any changes have been committed or they will be lost.
conn.close()

It have error:






---------------------------------------------------------------------------
ProgrammingError Traceback (most recent call last)
<ipython-input-12-350b4286edc5> in <module>()
----> 1 c = conn.cursor()
2
3 # Create table
4 c.execute('''CREATE TABLE stocks
5 (date text, trans text, symbol text, qty real, price real)''')

ProgrammingError: Cannot operate on a closed database.
Member 14891535 19-Jul-20 7:25am View    
Updated my questions, such a nice person you are. But I do not hope you will reply and help.
Member 14891535 19-Jul-20 4:43am View    
This is already solve, I posted long time ago. Thanks.