mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-29 21:03:45 +03:00
Handle SQLAlchemy import errors
This commit is contained in:
parent
c1a8896faa
commit
f805914c80
|
@ -1,6 +1,10 @@
|
||||||
|
try:
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
from sqlalchemy import Column, String, Integer, BLOB, orm
|
from sqlalchemy import Column, String, Integer, BLOB, orm
|
||||||
import sqlalchemy as sql
|
import sqlalchemy as sql
|
||||||
|
except ImportError:
|
||||||
|
sql = None
|
||||||
|
pass
|
||||||
|
|
||||||
from ..crypto import AuthKey
|
from ..crypto import AuthKey
|
||||||
from ..tl.types import InputPhoto, InputDocument
|
from ..tl.types import InputPhoto, InputDocument
|
||||||
|
@ -13,6 +17,8 @@ LATEST_VERSION = 1
|
||||||
class AlchemySessionContainer:
|
class AlchemySessionContainer:
|
||||||
def __init__(self, engine=None, session=None, table_prefix="",
|
def __init__(self, engine=None, session=None, table_prefix="",
|
||||||
table_base=None, manage_tables=True):
|
table_base=None, manage_tables=True):
|
||||||
|
if not sql:
|
||||||
|
raise ImportError("SQLAlchemy not imported")
|
||||||
if isinstance(engine, str):
|
if isinstance(engine, str):
|
||||||
engine = sql.create_engine(engine)
|
engine = sql.create_engine(engine)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user