forked from platypush/platypush
Better way to import declarative_base
from SQLAlchemy.
Import `declarative_base` in a way that is compatible with any SQLAlchemy version between 1.3 and 2.x.
This commit is contained in:
parent
8478245cde
commit
d33d760361
6 changed files with 19 additions and 6 deletions
|
@ -3,9 +3,10 @@ import os
|
||||||
from typing import Optional, Union, List, Dict, Any
|
from typing import Optional, Union, List, Dict, Any
|
||||||
|
|
||||||
from sqlalchemy import create_engine, Column, Integer, String, DateTime
|
from sqlalchemy import create_engine, Column, Integer, String, DateTime
|
||||||
from sqlalchemy.orm import sessionmaker, scoped_session, declarative_base
|
from sqlalchemy.orm import sessionmaker, scoped_session
|
||||||
|
|
||||||
from platypush.backend import Backend
|
from platypush.backend import Backend
|
||||||
|
from platypush.common.db import declarative_base
|
||||||
from platypush.config import Config
|
from platypush.config import Config
|
||||||
from platypush.context import get_plugin
|
from platypush.context import get_plugin
|
||||||
from platypush.message.event.covid19 import Covid19UpdateEvent
|
from platypush.message.event.covid19 import Covid19UpdateEvent
|
||||||
|
|
|
@ -6,9 +6,10 @@ from typing import Optional, List
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from sqlalchemy import create_engine, Column, String, DateTime
|
from sqlalchemy import create_engine, Column, String, DateTime
|
||||||
from sqlalchemy.orm import sessionmaker, scoped_session, declarative_base
|
from sqlalchemy.orm import sessionmaker, scoped_session
|
||||||
|
|
||||||
from platypush.backend import Backend
|
from platypush.backend import Backend
|
||||||
|
from platypush.common.db import declarative_base
|
||||||
from platypush.config import Config
|
from platypush.config import Config
|
||||||
from platypush.message.event.github import (
|
from platypush.message.event.github import (
|
||||||
GithubPushEvent,
|
GithubPushEvent,
|
||||||
|
|
|
@ -12,10 +12,11 @@ from sqlalchemy import (
|
||||||
ForeignKey,
|
ForeignKey,
|
||||||
)
|
)
|
||||||
|
|
||||||
from sqlalchemy.orm import sessionmaker, scoped_session, declarative_base
|
from sqlalchemy.orm import sessionmaker, scoped_session
|
||||||
from sqlalchemy.sql.expression import func
|
from sqlalchemy.sql.expression import func
|
||||||
|
|
||||||
from platypush.backend.http.request import HttpRequest
|
from platypush.backend.http.request import HttpRequest
|
||||||
|
from platypush.common.db import declarative_base
|
||||||
from platypush.config import Config
|
from platypush.config import Config
|
||||||
from platypush.context import get_plugin
|
from platypush.context import get_plugin
|
||||||
from platypush.message.event.http.rss import NewFeedEvent
|
from platypush.message.event.http.rss import NewFeedEvent
|
||||||
|
|
|
@ -9,9 +9,10 @@ from threading import Thread, RLock
|
||||||
from typing import List, Dict, Any, Optional, Tuple
|
from typing import List, Dict, Any, Optional, Tuple
|
||||||
|
|
||||||
from sqlalchemy import engine, create_engine, Column, Integer, String, DateTime
|
from sqlalchemy import engine, create_engine, Column, Integer, String, DateTime
|
||||||
from sqlalchemy.orm import sessionmaker, scoped_session, declarative_base
|
from sqlalchemy.orm import sessionmaker, scoped_session
|
||||||
|
|
||||||
from platypush.backend import Backend
|
from platypush.backend import Backend
|
||||||
|
from platypush.common.db import declarative_base
|
||||||
from platypush.config import Config
|
from platypush.config import Config
|
||||||
from platypush.context import get_plugin
|
from platypush.context import get_plugin
|
||||||
from platypush.message.event.mail import (
|
from platypush.message.event.mail import (
|
||||||
|
@ -40,6 +41,7 @@ class MailboxStatus(Base):
|
||||||
|
|
||||||
# </editor-fold>
|
# </editor-fold>
|
||||||
|
|
||||||
|
|
||||||
# <editor-fold desc="Mailbox model">
|
# <editor-fold desc="Mailbox model">
|
||||||
@dataclass
|
@dataclass
|
||||||
class Mailbox:
|
class Mailbox:
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
from sqlalchemy import __version__
|
||||||
|
|
||||||
|
sa_version = tuple(map(int, __version__.split('.')))
|
||||||
|
|
||||||
|
if sa_version >= (1, 4, 0):
|
||||||
from sqlalchemy.orm import declarative_base
|
from sqlalchemy.orm import declarative_base
|
||||||
|
else:
|
||||||
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
|
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
|
|
|
@ -12,9 +12,10 @@ from sqlalchemy import (
|
||||||
PrimaryKeyConstraint,
|
PrimaryKeyConstraint,
|
||||||
ForeignKey,
|
ForeignKey,
|
||||||
)
|
)
|
||||||
from sqlalchemy.orm import sessionmaker, scoped_session, declarative_base
|
from sqlalchemy.orm import sessionmaker, scoped_session
|
||||||
from sqlalchemy.sql.expression import func
|
from sqlalchemy.sql.expression import func
|
||||||
|
|
||||||
|
from platypush.common.db import declarative_base
|
||||||
from platypush.config import Config
|
from platypush.config import Config
|
||||||
from platypush.plugins.media import MediaPlugin
|
from platypush.plugins.media import MediaPlugin
|
||||||
from platypush.plugins.media.search import MediaSearcher
|
from platypush.plugins.media.search import MediaSearcher
|
||||||
|
|
Loading…
Reference in a new issue