mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-09 05:19:41 +00:00
Handle SQLAlchemy import errors
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
from sqlalchemy.ext.declarative import declarative_base
|
try:
|
||||||
from sqlalchemy import Column, String, Integer, BLOB, orm
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
import sqlalchemy as sql
|
from sqlalchemy import Column, String, Integer, BLOB, orm
|
||||||
|
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)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user