mirror of
https://github.com/283375/arcaea-offline.git
synced 2025-04-19 22:20:17 +00:00
impr: use Session
instead of Engine
in write_database
of external parsers
This commit is contained in:
parent
a2193a7d1b
commit
b334108f8c
5
src/arcaea_offline/external/arcaea/common.py
vendored
5
src/arcaea_offline/external/arcaea/common.py
vendored
@ -2,7 +2,6 @@ import json
|
|||||||
from os import PathLike
|
from os import PathLike
|
||||||
from typing import Any, List, Optional, Union
|
from typing import Any, List, Optional, Union
|
||||||
|
|
||||||
from sqlalchemy import Engine
|
|
||||||
from sqlalchemy.orm import DeclarativeBase, Session
|
from sqlalchemy.orm import DeclarativeBase, Session
|
||||||
|
|
||||||
|
|
||||||
@ -47,9 +46,7 @@ class ArcaeaParser:
|
|||||||
def parse(self) -> List[DeclarativeBase]:
|
def parse(self) -> List[DeclarativeBase]:
|
||||||
...
|
...
|
||||||
|
|
||||||
def write_database(self, engine: Engine):
|
def write_database(self, session: Session):
|
||||||
with Session(engine) as session:
|
|
||||||
results = self.parse()
|
results = self.parse()
|
||||||
for result in results:
|
for result in results:
|
||||||
session.merge(result)
|
session.merge(result)
|
||||||
session.commit()
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from sqlalchemy import Engine
|
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from ...models.songs import ChartInfo
|
from ...models.songs import ChartInfo
|
||||||
@ -29,9 +28,7 @@ class ArcsongDbParser:
|
|||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def write_database(self, engine: Engine):
|
def write_database(self, session: Session):
|
||||||
with Session(engine) as session:
|
|
||||||
results = self.parse()
|
results = self.parse()
|
||||||
for result in results:
|
for result in results:
|
||||||
session.merge(result)
|
session.merge(result)
|
||||||
session.commit()
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user