1
1
forked from iarv/meshview
Files
meshview/meshview/database.py
T
Pablo Revilla 0831301997 Multiple changes to the code. Important to mentioned:
- We added another column to the nodes table to report on firmware version

- Also changed the date and time format to be more readable.

- Added a node list report

- Modified the Mesh Graphs
2025-02-07 21:18:02 -08:00

17 lines
652 B
Python

from meshview import models
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker
def init_database(database_connection_string):
global engine, async_session
kwargs = {}
if not database_connection_string.startswith('sqlite'):
kwargs['pool_size'] = 20
kwargs['max_overflow'] = 50
print (**kwargs)
engine = create_async_engine(database_connection_string, echo=False, connect_args={"timeout": 15})
async_session = async_sessionmaker(engine, expire_on_commit=False)
async def create_tables():
async with engine.begin() as conn:
await conn.run_sync(models.Base.metadata.create_all)