示例#1
0
文件: bd.py 项目: paredesivan/botcito
def inicializar_bd():

    engine = create_engine(
        'postgres://*****:*****@tuffi.db.elephantsql.com:5432/edhyrpuf',
    )

    # enlaza clases con tablas
    start_mappers()

    # crea las tablas en la base de datos (no importa el start mapper!
    metadata.create_all(engine)

    # enlaza la sesion con la base de datos
    Session = sessionmaker(bind=engine)

    # crea una sesion
    return Session()
示例#2
0
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

from adapters.orm import (
    metadata,
    map_one_to_many,
    map_many_to_one,
    map_one_to_one,
    map_many_to_many,
)
from domain.model import User, Mail, City, Customer, Employee, Pay, Tag, Post

# mapping classes
map_one_to_many()
map_many_to_one()
map_one_to_one()
map_many_to_many()

# create the engine
engine = create_engine("sqlite:///database.db", echo=True)

# create all the database
metadata.create_all(bind=engine)

# create the session
Session = sessionmaker(bind=engine)

# initiate the session
session = Session()
示例#3
0
def get_sqlite_engine():
    print("diretorio sqlite: ", BASE_DIR)
    engine = create_engine('sqlite:///' + os.path.join(BASE_DIR, 'db.sqlite3'))
    metadata.create_all(engine)
    return engine
示例#4
0
def get_postgres_engine():
    engine = create_engine(get_postgres_uri(), isolation_level="REPEATABLE READ", )
    metadata.create_all(engine)  # eh esse comando que gera a base de dados
    return engine
示例#5
0
def postgres_db():
    engine = create_engine(config.get_postgres_uri(), isolation_level="SERIALIZABLE")
    wait_for_postgres_to_come_up(engine)
    metadata.create_all(engine)
    return engine
示例#6
0
def in_memory_sqlite_db():
    engine = create_engine("sqlite:///:memory:")
    metadata.create_all(engine)
    return engine
def postgres_db():
    engine = create_engine(config.get_postgres_uri())
    wait_for_postgres_to_come_up(engine)
    metadata.create_all(engine)
    return engine
示例#8
0
def in_real_db():
    engine = create_engine('sqlite:///' + os.path.join(BASE_DIR, 'db.sqlite3'))
    metadata.create_all(engine)
    return engine
示例#9
0
def in_memory_db():
    # engine = create_engine('postgres://*****:*****@tuffi.db.elephantsql.com:5432/edhyrpuf')
    engine = create_engine('postgres:///:memory:')
    metadata.create_all(engine)
    return engine