-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
105 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import asyncio | ||
|
||
from sqlalchemy import Column, DateTime, Identity, Integer, MetaData, String, Table | ||
from sqlalchemy.ext.asyncio import create_async_engine | ||
|
||
from src.config import settings | ||
|
||
|
||
DATABASE_URL = settings.DATABASE_URL | ||
|
||
engine = create_async_engine(DATABASE_URL) | ||
|
||
metadata = MetaData() | ||
|
||
event = Table( | ||
"event", | ||
metadata, | ||
Column("id", Integer, Identity(), primary_key=True), | ||
Column("product", String, nullable=False), | ||
Column("pennkey", String, nullable=True), | ||
Column("datapoint", String, nullable=False), | ||
Column("value", String, nullable=False), | ||
Column("timestamp", DateTime, nullable=False), | ||
) | ||
|
||
|
||
# Create all tables in the metadata | ||
async def create_tables(): | ||
async with engine.begin() as conn: | ||
await conn.run_sync(metadata.create_all) | ||
|
||
|
||
asyncio.run(create_tables()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters