2

Hello there i am just working with sqlite3 in python (3.9) and have the following basic command.

import sqlite3

conn = sqlite3.connect(r'C:\python\pythonCode\NewDB.db')
cursor = conn.cursor()
sql = '''create table students (
    id int,
    name text,
    username text)'''
cursor.execute(sql)
cursor.close()

i dont get any errors when i run i cannot see any db file in the C: location in the connect()

Can someone point me in the right direction please.

1 Answer 1

2

This code seems fine to me - but by the behaviour you describe, it sounds as if your application is not getting sufficient rights to create the file: you are telling your code to create a file within your C:\python directory.

I would suggest running your Python script as administrator [run CMD as admin and then python3 file.py]. If you don't want to go down this route, then change the database directory to something like your desktop to avoid any privilege issues.

I hope this solves your error! Let me know.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.