Skip to content

Instantly share code, notes, and snippets.

@mujeebishaque
Created March 18, 2022 20:08
Show Gist options
  • Save mujeebishaque/ce72016a480ac739c355083f03b28f53 to your computer and use it in GitHub Desktop.
Save mujeebishaque/ce72016a480ac739c355083f03b28f53 to your computer and use it in GitHub Desktop.
create database and table sqlite3
def create_if_not_exists():
try:
import sqlite3
connection = sqlite3.connect('database.db')
cursor = connection.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS listings
(listing_url TEXT, current_price TEXT)
''')
show_success("SUCCESS: Connected to the database!")
except:
show_error("ERROR: Can't create a database in this directory!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment