Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sqlalchemy==2.0.43
pytest==8.4.1
pytest-cov==6.2.1
pdoc==15.0.4
flake8==7.3.0
pdoc==15.0.4
1 change: 1 addition & 0 deletions stat_log_db/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ description = ""
readme = "README.md"
requires-python = ">=3.12.10"
dependencies = [
"sqlalchemy==2.0.43"
]

[project.optional-dependencies]
Expand Down
4 changes: 0 additions & 4 deletions stat_log_db/src/stat_log_db/__init__.py

This file was deleted.

46 changes: 30 additions & 16 deletions stat_log_db/src/stat_log_db/cli.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import os
# import os
# import sys

from sqlalchemy import select
from sqlalchemy.orm import Session

# from .parser import create_parser
from .db import MemDB # , FileDB, Database, BaseConnection
from stat_log_db.db import Database as DB
from stat_log_db.modules.log import Log, LogType, LogLevel


def main():
Expand All @@ -18,21 +22,31 @@ def main():

# print(f"{args=}")

sl_db = MemDB({
"is_mem": True,
"fkey_constraint": True
sl_db = DB({
"is_mem": True
})
con = sl_db.init_db(True)
con.create_table("test", [('notes', 'TEXT')], False, True)
con.execute("INSERT INTO test (notes) VALUES (?);", ("Hello world!",))
con.commit()
con.execute("SELECT * FROM test;")
sql_logs = con.fetchall()
print(sql_logs)
con.drop_table("test", True)
sl_db.close_db()
if sl_db.is_file:
os.remove(sl_db.file_name)
sl_db.init_db()
with Session(sl_db.engine) as session:
info_type = LogType(
name="INFO"
)
session.add(info_type)
session.commit()
info_level = LogLevel(
name="INFO"
)
session.add(info_level)
session.commit()
hello_world = Log(
type_id=1,
level_id=1,
message="Hello, World!"
)
session.add(hello_world)
session.commit()
logs = select(Log).where(Log.id == 1)
for log in session.scalars(logs):
print(f"{log.id=}, {log.type_id=}, {log.level_id=}, {log.message=}")


if __name__ == "__main__":
Expand Down
Loading