Created
June 23, 2022 12:50
-
-
Save jaydeepkarale/fba7e812f1344e99bb582b80ed64a6bf to your computer and use it in GitHub Desktop.
Initialise a sqlitedb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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