Add simple Duck model

This commit is contained in:
Gábor Barna 2016-10-28 05:26:16 +02:00
parent 039855db6f
commit 70a5a99909
2 changed files with 21 additions and 0 deletions

6
app.py
View File

@ -7,8 +7,14 @@ import sqlalchemy
from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
import models
engine = create_engine( os.environ.get( 'DATABASE_URL', 'sqlite:///:memory:' ), echo=True )
Base.metadata.create_all( engine )
app = connexion.App(__name__, specification_dir='./swagger/')
app.add_api('swagger.yaml',
arguments={

15
models.py Normal file
View File

@ -0,0 +1,15 @@
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Duck( Base ):
__tablename__ = 'users'
duck_id = Column( Integer, primary_key=True )
name = Column( String )
color = Column( String )
def __repr__(self):
return "<User(name='%s', fullname='%s', password='%s')>" % (
self.name, self.fullname, self.password)