-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase_setup.py
More file actions
39 lines (30 loc) · 1.16 KB
/
database_setup.py
File metadata and controls
39 lines (30 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from sqlalchemy import Column, ForeignKey, Integer, String, Boolean, Date, DateTime, Float, Interval, Time, Unicode
# from sqlalchemy import Numeric, BigInteger, SmallInteger, Text, UnicodeText, Enum, PickleType, LargeBinary, MatchType, SchemaType
from sqlalchemy.dialects.postgresql import ARRAY, JSON
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy import create_engine
# from enum import Enum
# class MyEnum(enum.Enum):
# one = 'one'
# two = 'two'
# three = 'three'
Base = declarative_base()
class Test(Base):
__tablename__ = 'test'
id = Column(Integer, primary_key=True)
integer = Column(Integer)
floatpt = Column(Float)
string = Column(String(500))
uni = Column(Unicode)
boolean = Column(Boolean)
date = Column(Date)
time = Column(Time)
datetime = Column(DateTime)
interval = Column(Interval)
int_array = Column(ARRAY(Integer))
str_array = Column(ARRAY(String(9999)))
json_object = Column(JSON)
# enum = Column(Enum(MyEnum))
engine = create_engine('postgresql://vagrant:password@localhost/playground')
Base.metadata.create_all(engine)