Add simple Duck model
This commit is contained in:
		
							
								
								
									
										6
									
								
								app.py
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								app.py
									
									
									
									
									
								
							| @@ -7,8 +7,14 @@ import sqlalchemy | |||||||
| from sqlalchemy import create_engine, Column, Integer, String | from sqlalchemy import create_engine, Column, Integer, String | ||||||
| from sqlalchemy.ext.declarative import declarative_base | from sqlalchemy.ext.declarative import declarative_base | ||||||
|  |  | ||||||
|  | Base = declarative_base() | ||||||
|  |  | ||||||
|  | import models | ||||||
|  |  | ||||||
| engine = create_engine( os.environ.get( 'DATABASE_URL', 'sqlite:///:memory:' ), echo=True ) | 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 = connexion.App(__name__, specification_dir='./swagger/') | ||||||
| app.add_api('swagger.yaml', | app.add_api('swagger.yaml', | ||||||
|             arguments={ |             arguments={ | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								models.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								models.py
									
									
									
									
									
										Normal 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) | ||||||
		Reference in New Issue
	
	Block a user