Skip to content

Commit

Permalink
🚀 BUMP: v0.8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Thaza-Kun committed Mar 28, 2023
1 parent 877cf21 commit a703c1c
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "samudra"
version = "0.8.0"
version = "0.8.3"
description = ""
authors = ["Thaza_Kun <[email protected]>"]

Expand Down
6 changes: 3 additions & 3 deletions samudra/conf/database/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

import peewee as pw

from conf.local import (
from samudra.conf.local import (
read_database_info,
write_config,
read_config,
append_database_list,
)
from models.base import database_proxy
from samudra.models.base import database_proxy
from samudra.conf.database.options import DatabaseEngine

db_state_default = {"closed": None, "conn": None, "ctx": None, "transactions": None}
Expand Down Expand Up @@ -82,7 +82,7 @@ def get_database(name: str) -> pw.Database:
"""Returns the connection class based on the name."""
info = read_database_info(name)
if info.get("engine") == DatabaseEngine.SQLite:
return_db = pw.SqliteDatabase(info.get("path"))
return_db = pw.SqliteDatabase(info.get("path"), check_same_thread=False)
return_db._state = SQLiteConnectionState()
return return_db
if info.get("engine") == DatabaseEngine.MySQL:
Expand Down
13 changes: 11 additions & 2 deletions samudra/conf/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@
import pytomlpp as toml

from samudra.conf import get_database
from samudra.conf.database.core import get_active_database
from samudra.conf.database.options import DatabaseEngine
from samudra.models.base import database_proxy

settings = toml.load("conf.toml")
try:
settings = toml.load("conf.toml")
except FileNotFoundError:
pass


def access_database(local: bool = True, name: str = None) -> peewee.Database:
if local:
return get_database(name=name, engine=DatabaseEngine.SQLite, new=False)
else:
raise NotImplementedError("Only loca database is implemented")
raise NotImplementedError("Only local database is implemented")


def bind_proxy_with_active_database() -> None:
database_proxy.initialize(get_active_database())
4 changes: 2 additions & 2 deletions samudra/core/crud/cakupan.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ def get_cakupan_by_id(
)


def delete_lemma(lemma: models.Cakupan) -> int:
return lemma.delete_instance(recursive=False)
def delete_cakupan(cakupan: models.Cakupan) -> int:
return cakupan.delete_instance(recursive=False)
5 changes: 5 additions & 0 deletions samudra/core/stats/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from samudra import models


def count_lemma() -> int:
return len(models.Lemma.select(models.Lemma.id))
4 changes: 2 additions & 2 deletions samudra/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typer import Typer

from conf.database.core import get_active_database
from models.base import database_proxy
from samudra.conf.database.core import get_active_database
from samudra.models.base import database_proxy
from samudra.cli import database, lemma, golongan_kata

app = Typer()
Expand Down
2 changes: 1 addition & 1 deletion samudra/server/routes/lemmas.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ def delete_lemma(_id: int, token: str = Depends(oauth2_scheme)) -> Dict[str, int
Returns how many items are deleted.
"""
lemma = crud.get_lemma_by_id(_id)[0]
return {"deleted": crud.delete_lemma(lemma)}
return {"deleted": crud.delete_cakupan(lemma)}
2 changes: 1 addition & 1 deletion samudra/server/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import peewee as pw

from conf.setup import settings
from samudra.conf.setup import settings
from samudra.conf import get_database
from samudra.conf.database.options import DatabaseEngine
from samudra.models import create_tables
Expand Down

0 comments on commit a703c1c

Please sign in to comment.