Created
September 8, 2014 19:09
-
-
Save zircote/91bb5699bec824b7cc6b to your computer and use it in GitHub Desktop.
Quick hack to setup the database for docker-registry thats not a sqlite bla blah
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 sqlalchemy | |
import sqlalchemy.exc | |
import sqlalchemy.ext.declarative | |
import sqlalchemy.orm | |
import sqlalchemy.sql.functions | |
from sqlalchemy import create_engine | |
engine = create_engine('postgresql://user:[email protected]/db_name') | |
Base = sqlalchemy.ext.declarative.declarative_base(bind=engine) | |
class Version (Base): | |
"Schema version for the search-index database" | |
__tablename__ = 'version' | |
id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True) | |
def __repr__(self): | |
return '<{0}(id={1})>'.format(type(self).__name__, self.id) | |
class Repository (Base): | |
"Repository description" | |
__tablename__ = 'repository' | |
id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True) | |
name = sqlalchemy.Column( | |
sqlalchemy.String, nullable=False, unique=True) | |
description = sqlalchemy.Column(sqlalchemy.String) | |
def __repr__(self): | |
return "<{0}(name='{1}', description='{2}')>".format( | |
type(self).__name__, self.name, self.description) | |
Base.metadata.create_all() |
Author
zircote
commented
Sep 8, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment