Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 7 additions & 6 deletions scraperwiki/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def new_transaction(cls):
@classmethod
def reflect_metadata(cls):
if cls.metadata is None:
cls.metadata = sqlalchemy.MetaData(bind=cls.engine)
cls.metadata.reflect()
cls.metadata = sqlalchemy.MetaData()
cls.metadata.reflect(bind=cls.engine)

@classmethod
def check_last_committed(cls):
Expand Down Expand Up @@ -197,7 +197,7 @@ def save(unique_keys, data, table_name='swdata'):
raise TypeError("Data must be a single mapping or an iterable "
"of mappings")

insert = _State.table.insert(prefixes=['OR REPLACE'])
insert = sqlalchemy.insert(_State.table).prefix_with('OR REPLACE')
for row in data:
if not isinstance(row, Mapping):
raise TypeError("Elements of data must be mappings, got {}".format(
Expand Down Expand Up @@ -251,7 +251,7 @@ def save_var(name, value):
keep_existing=True
)

vars_table.create(bind=connection, checkfirst=True)
vars_table.create(connection, checkfirst=True)

column_type = get_column_type(value)

Expand All @@ -265,8 +265,9 @@ def save_var(name, value):
# value_blob=Blob(value),
type=column_type.__visit_name__.lower())

vars_table.insert(prefixes=['OR REPLACE']).values(**values).execute()

stmt = vars_table.insert(prefixes=['OR REPLACE']).values(**values)
connection.execute(stmt)
_State.new_transaction()

def get_var(name, default=None):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def has_external_dependency(name):
try:
from setuptools import setup
config['install_requires'] = ['requests', 'six',
'sqlalchemy==1.3.0', 'alembic==1.14.0'],
'sqlalchemy==1.4.54', 'alembic==1.17.2'],
except ImportError:
pass

Expand Down
Loading