Commit 7b2462b1 authored by Emanuele Santoro's avatar Emanuele Santoro

Initial database implementation

parent 49be16ed
#!/usr/bin/env python3
import os
import sqlalchemy
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String
Base = declarative_base()
class Link(Base) :
__tablename__ = "links"
id = Column(Integer, primary_key=True)
url = Column(String)
short = Column(String)
def __init__(self, url, short) :
self.url = url
self.short = short
def __repr__(self) :
return "<Link(id='%d', short='%s', url='%s')>" % (self.id, self.short, self.url)
def create_connection() :
DB_URL = os.getenv("DATABASE_URL")
DB_TYPE = os.getenv("DB_TYPE")
engine = create_engine(DB_URL, echo=True)
return engine
manu@nadia.16918:1460031346
\ No newline at end of file
#!/usr/bin/env python3
import os
import sqlalchemy
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String
Base = declarative_base()
class Link(Base) :
__tablename__ = "links"
id = Column(Integer, primary_key=True)
url = Column(String)
short = Column(String)
def __init__(self, url, short) :
self.url = url
self.short = short
def __repr__(self) :
return "<Link(id='%d', short='%s', url='%s')>" % (self.id, self.short, self.url)
def create_connection() :
DB_URL = os.getenv("DATABASE_URL")
DB_TYPE = os.getenv("DB_TYPE")
engine = create_engine(DB_URL, echo=True)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment