Create a Table if it Does not Exist:
import sqlite3
import os
current_directory = os.path.dirname(os.path.abspath(__file__))
db_name = 'your_database.db'
file_path = os.path.join(current_directory, db_name)
conn = sqlite3.connect(file_path)
cursor = conn.cursor()
create_table = '''
create table if not exists your_table(
id integer primary key,
name text,
email text
)
'''
cursor.execute(create_table)
conn.commit()
conn.close()
Be the first to comment