please help! I am using sqlite3 in ipython notebook to create an SQL database. I think I have successfully created the database, but when I go to look at it I am receiving an encoding UTF8 error. Here is my code:
import sqlite3
conn=sqlite3.connect('example.db')
c=conn.cursor()
c.execute('''DROP TABLE PROFILE''')
c.execute('''CREATE TABLE PROFILE
( FIRSTNAME TEXT PRIMARY KEY unique NOT NULL,
LASTNAME TEXT NOT NULL,
EMAILADDRESS TEXT NOT NULL,
PASSWORD TEXT NOT NULL,
CURRENTJOBTITLE TEXT NOT NULL,
EDUCATION TEXT NOT NULL);''')
conn.close()
conn = sqlite3.connect('example.db')
c = conn.cursor()
conn.execute("INSERT INTO PROFILE (FIRSTNAME, LASTNAME, EMAILADDRESS, PASSWORD, CURRENTJOBTITLE, EDUCATION) \
VALUES ('SALLYSUE','SUE','[email protected]','ABC', 'STUDENT', 'GRAD')");
conn.commit()
conn.close()
This is the end of my Code. When I go to look at the file created 'example.db' this is where I see the below error:
Error! C:\Users\Lastname\CSE801\example.db is not UTF-8 encoded
Saving disabled.
See Console for more details
So I am not able to see the table I am creating in SQL.
I googled this and found that people said to put this in my code
import sys
reload(sys)
sys.setdefaultencoding()
Well once I do this and try to rerun my code the code produces nothing. It won't run the code at all. Does anyone have any suggestions? Thanks!
I am a complete newbie in Python and faced the similar issue. But i soon realized i was trying to access a zip folder from Jupyter and hence the error!! Unzip and access the actual file was to be done in the first place.
This may sound very basic, but it might happen to new coders.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With