Skip to content

Instantly share code, notes, and snippets.

@jaydeepkarale
Created June 23, 2022 12:50
Show Gist options
  • Save jaydeepkarale/fba7e812f1344e99bb582b80ed64a6bf to your computer and use it in GitHub Desktop.
Save jaydeepkarale/fba7e812f1344e99bb582b80ed64a6bf to your computer and use it in GitHub Desktop.
Initialise a sqlitedb
import sqlite3
from aiohttp import web
# create a sqllite db
connection = sqlite3.connect("urlshortner.db")
cursor = connection.cursor()
routes = web.RouteTableDef()
if __name__ == "__main__":
cursor.execute("CREATE TABLE IF NOT EXISTS URLSHORTNER (longurl TEXT, shorturl TEXT, code TEXT UNIQUE)")
app = web.Application()
app.add_routes(routes)
web.run_app(app, port=8000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment