Created
July 13, 2021 11:58
-
-
Save ArtemD/0e5693c142c6cf24a5001b7b334ccff8 to your computer and use it in GitHub Desktop.
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 csv | |
import os | |
from pprint import pprint as pp | |
from sqlalchemy import create_engine, text | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy import Column, String, Integer, DateTime | |
from sqlalchemy.orm import sessionmaker | |
from datetime import datetime | |
from sqlalchemy.orm.session import Session | |
sqlite = 'sqlite:///sql.db' | |
Base = declarative_base() | |
class License(Base): | |
__tablename__ = 'licenses' | |
id = Column(Integer, primary_key=True) | |
""" Primary key """ | |
name = Column(String(255)) | |
""" License holder's name """ | |
address = Column(String(255)) | |
""" Address """ | |
postcode = Column(String(255)) | |
""" Postcode """ | |
city = Column(String(255)) | |
""" City """ | |
license_granting_date = Column(String(255)) | |
""" License granting date in format dd.mm.yyyy """ | |
license_type = Column(String(255)) | |
""" License type as a string (in Finnish) """ | |
business_id = Column(String(255)) | |
""" Business id or N/A if not applicable """ | |
created_at = Column(DateTime, default=datetime.utcnow) | |
""" Automatically generated date and time of insertion """ | |
def __repr__(self): | |
""" String representation of the object """ | |
return "<License (name='%s', created_at='%s')>" % (self.name, self.created_at) | |
db = create_engine(sqlite) | |
Session = sessionmaker(bind=db) | |
Base.metadata.create_all(db) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment