Exemple #1
0
 def get_create_view_obj(self, meta_data: MetaData):
     view = Table(self._name, meta_data)
     create_view_obj = CreateView(view,
                                  self._select_statement,
                                  or_replace=False)
     print(str(create_view_obj.compile()).strip())
     return create_view_obj
Exemple #2
0
    def __init__(self, bot):
        self.bot = bot

        # View追加 TODO: テーブル、View作成は別ファイルに分離したい。
        if not engine.dialect.has_table(engine, 'reaction_count'):
            view = Table('reaction_count', MetaData())
            definition = text("SELECT emoji_id, count(emoji_id) as count FROM message_reaction GROUP BY emoji_id")
            create_view = CreateView(view, definition)
            print(str(create_view.compile()).strip())
            engine.execute(create_view)
Exemple #3
0
async def on_ready():
    # View追加
    if not engine.dialect.has_table(engine, 'reaction_count'):
        view = Table('reaction_count', MetaData())
        definition = text(
            "SELECT emoji_id, count(emoji_id) as count FROM message_reaction GROUP BY emoji_id"
        )
        create_view = CreateView(view, definition)
        print(str(create_view.compile()).strip())
        engine.execute(create_view)
    print('We have logged in as {0.user}'.format(bot))
Exemple #4
0
import sqlalchemy as db
from sqlalchemy_views import CreateView, DropView
from sqlalchemy.sql import text

engine = db.create_engine('sqlite:////tmp/test2.db', echo=True)

conn = engine.connect()

metadata = db.MetaData()

field = db.Table('field', metadata, autoload=True, autoload_with=engine)

view = db.Table('my_view', metadata)
create_view = CreateView(view, text("SELECT * FROM field"))

print(create_view.compile())