Skip to content

use registry.map_imperatively instead of deprecated mapper #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sqlalchemy import (
Table, MetaData, Column, Integer, String,
ForeignKey, create_engine, select)
from sqlalchemy.orm import mapper, sessionmaker
from sqlalchemy.orm import registry, sessionmaker
from sqlalchemy.orm.exc import NoResultFound
from errbot.storage.base import StorageBase, StoragePluginBase

Expand Down Expand Up @@ -104,7 +104,8 @@ def __init__(self, bot_config):
pool_recycle=config.get('connection_recycle', 1800),
pool_pre_ping=config.get('connection_ping', True),
echo=bot_config.BOT_LOG_LEVEL == logging.DEBUG)
self._metadata = MetaData()
self._mapper_registry = registry()
self._metadata = self._mapper_registry.metadata
self._sessionmaker = sessionmaker()
self._sessionmaker.configure(bind=self._engine)

Expand All @@ -119,7 +120,7 @@ def open(self, namespace: str) -> StorageBase:
class NewKV(KV):
pass

mapper(NewKV, table, properties={
self._mapper_registry.map_imperatively(NewKV, table, properties={
'_key': table.c.key,
'_value': table.c.value})

Expand Down