'method' object is not iterable when trying to add data to database - python

I'm using sqlalchemy to insert data into a table, but the error 'method' object is not iterable' is displayed in the console. How can I fix this? Here is my code:
with engine.connect() as conn:
conn.execute(
insert(text('users')).values(
{"fio": name, "datar": '11.08.1984', "id_role": randint(1, 2)}
))
conn.commit()
Here are the errors that are thrown:
File "C:\Users\gibso\PycharmProjects\test_task\main.py", line 41, in registration
conn.execute(
File "C:\Users\gibso\PycharmProjects\test_task\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1011, in execute
return meth(self, multiparams, params)
File "C:\Users\gibso\PycharmProjects\test_task\venv\lib\site-packages\sqlalchemy\sql\elements.py", line 298, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "C:\Users\gibso\PycharmProjects\test_task\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1115, in _execute_clauseelement
compiled_sql = elem.compile(
File "<string>", line 1, in <lambda>
File "C:\Users\gibso\PycharmProjects\test_task\venv\lib\site-packages\sqlalchemy\sql\elements.py", line 481, in compile
return self._compiler(dialect, bind=bind, **kw)
File "C:\Users\gibso\PycharmProjects\test_task\venv\lib\site-packages\sqlalchemy\sql\elements.py", line 487, in _compiler
return dialect.statement_compiler(dialect, self, **kw)
File "C:\Users\gibso\PycharmProjects\test_task\venv\lib\site-packages\sqlalchemy\sql\compiler.py", line 592, in __init__
Compiled.__init__(self, dialect, statement, **kwargs)
File "C:\Users\gibso\PycharmProjects\test_task\venv\lib\site-packages\sqlalchemy\sql\compiler.py", line 322, in __init__
self.string = self.process(self.statement, **compile_kwargs)
File "C:\Users\gibso\PycharmProjects\test_task\venv\lib\site-packages\sqlalchemy\sql\compiler.py", line 352, in process
return obj._compiler_dispatch(self, **kwargs)
File "C:\Users\gibso\PycharmProjects\test_task\venv\lib\site-packages\sqlalchemy\sql\visitors.py", line 96, in _compiler_dispatch
return meth(self, **kw)
File "C:\Users\gibso\PycharmProjects\test_task\venv\lib\site-packages\sqlalchemy\sql\compiler.py", line 2467, in visit_insert
crud_params = crud._setup_crud_params(
File "C:\Users\gibso\PycharmProjects\test_task\venv\lib\site-packages\sqlalchemy\sql\crud.py", line 64, in _setup_crud_params
return _get_crud_params(compiler, stmt, **kw)
File "C:\Users\gibso\PycharmProjects\test_task\venv\lib\site-packages\sqlalchemy\sql\crud.py", line 158, in _get_crud_params
_scan_cols(
File "C:\Users\gibso\PycharmProjects\test_task\venv\lib\site-packages\sqlalchemy\sql\crud.py", line 316, in _scan_cols
for c in cols:
TypeError: 'method' object is not iterable

Related

VARCHAR column is not compatible with autoincrement=True

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Sequence, Integer, Float, String, Boolean, ForeignKey, TIMESTAMP, Enum
import datetime
from os import urandom
from binascii import hexlify
from hashlib import sha1
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = "postgresql://postgres:neljaD44#localhost:5432/postgress";
db = SQLAlchemy(app)
After running this file I get following error.
python2.7 create_postgresql_database.py
/usr/local/lib/python2.7/dist-packages/flask_sqlalchemy/__init__.py:873: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning.
'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
Traceback (most recent call last):
File "create_postgresql_database.py", line 903, in <module>
db.create_all()
File "/usr/local/lib/python2.7/dist-packages/flask_sqlalchemy/__init__.py", line 1094, in create_all
self._execute_for_all_tables(app, bind, 'create_all')
File "/usr/local/lib/python2.7/dist-packages/flask_sqlalchemy/__init__.py", line 1086, in _execute_for_all_tables
op(bind=self.get_engine(app, bind), **extra)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/schema.py", line 4745, in create_all
ddl.SchemaGenerator, self, checkfirst=checkfirst, tables=tables
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 3079, in _run_ddl_visitor
conn._run_ddl_visitor(visitorcallable, element, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2081, in _run_ddl_visitor
visitorcallable(self.dialect, self, **kwargs).traverse_single(element)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/visitors.py", line 485, in traverse_single
return meth(obj, **kw)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/ddl.py", line 850, in visit_metadata
_is_metadata_operation=True,
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/visitors.py", line 485, in traverse_single
return meth(obj, **kw)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/ddl.py", line 895, in visit_table
include_foreign_key_constraints, # noqa
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1262, in execute
return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/ddl.py", line 78, in _execute_on_connection
self, multiparams, params, execution_options
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1350, in _execute_ddl
dialect=dialect, schema_translate_map=schema_translate_map
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", line 522, in compile
return self._compiler(dialect, **kw)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/ddl.py", line 29, in _compiler
return dialect.ddl_compiler(dialect, self, **kw)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/compiler.py", line 455, in __init__
self.string = self.process(self.statement, **compile_kwargs)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/compiler.py", line 490, in process
return obj._compiler_dispatch(self, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/visitors.py", line 81, in _compiler_dispatch
return meth(self, **kw)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/compiler.py", line 4025, in visit_create_table
create_column, first_pk=column.primary_key and not first_pk
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/compiler.py", line 490, in process
return obj._compiler_dispatch(self, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/visitors.py", line 81, in _compiler_dispatch
return meth(self, **kw)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/compiler.py", line 4058, in visit_create_column
text = self.get_column_specification(column, first_pk=first_pk)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/dialects/postgresql/base.py", line 2474, in get_column_specification
and column is column.table._autoincrement_column
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/schema.py", line 810, in _autoincrement_column
return self.primary_key._autoincrement_column
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 1097, in __get__
obj.__dict__[self.__name__] = result = self.fget(obj)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/schema.py", line 3954, in _autoincrement_column
_validate_autoinc(col, True)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/schema.py", line 3928, in _validate_autoinc
"compatible with autoincrement=True" % (col.type, col)
sqlalchemy.exc.ArgumentError: Column type VARCHAR(64) on column 'sessions.session_id' is not compatible with autoincrement=True
root#bdnewsbdnews:/home/khondakar/Desktop#
You cannot have a VARCHAR column set to autoincrement = True. You should use an INTEGER column (for instance, most common) instead.

Iam trying to install a new module in odoo but error occuring, AttributeError: 'str' object has no attribute 'setdefault'

I am trying to use the ODOO server, however I am getting this exception. Seems like a configuraton issue:
Traceback (most recent call last):
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/http.py", line 640, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/http.py", line 316, in _handle_exception
raise exception.with_traceback(None) from new_cause
**AttributeError: 'str' object has no attribute 'setdefault'**
Odoo Server Error
Traceback (most recent call last):
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/http.py", line 684, in dispatch
result = self._call_function(**self.params)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/http.py", line 360, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/http.py", line 348, in checked_call
result = self.endpoint(*a, **kw)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/http.py", line 913, in __call__
return self.method(*args, **kw)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/http.py", line 532, in response_wrap
response = f(*args, **kw)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/addons/web/controllers/main.py", line 1368, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/addons/web/controllers/main.py", line 1356, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/api.py", line 396, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/api.py", line 383, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-71>", line 2, in button_immediate_install
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/addons/base/models/ir_module.py", line 73, in check_and_log
return method(self, *args, **kwargs)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/addons/base/models/ir_module.py", line 474, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/addons/base/models/ir_module.py", line 592, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/modules/registry.py", line 89, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/modules/loading.py", line 453, in load_modules
processed_modules += load_marked_modules(cr, graph,
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/modules/loading.py", line 346, in load_marked_modules
loaded, processed = load_module_graph(
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/modules/loading.py", line 197, in load_module_graph
registry.setup_models(cr)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/modules/registry.py", line 269, in setup_models
model._setup_base()
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/models.py", line 2780, in _setup_base
self._add_field(name, field.new())
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/models.py", line 402, in _add_field
field.setup_base(self, name)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/fields.py", line 278, in setup_base
self._setup_attrs(model, name)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/fields.py", line 2282, in _setup_attrs
ondelete.setdefault(key, 'set null')
Exception
The above exception was the direct cause of the following exception:

Unknown PG numeric type 25

I am working on a project with Python-Flask, SQL Alchemy, & Postgres qith psycopg2 package.
The project's save the data in database successfully, but throws error "Unknown PG numeric type 25" while refreshing object.
project.second_payment_percent = int(request.form.get("second_payment_percent", 0)) if request.form.get("second_payment_percent", 0) else 0
project.second_payment_before = int(request.form.get("second_payment_before", 120))
project.currency_id = int(request.form.get("currency_code"))
project.security_deposit = int(request.form.get("security_deposit", 0))
project.apa = int(request.form.get("apa", 0))
project.vat_schema_id = request.form.get("vat_schema") if request.form.get("vat_schema", 0) else None
if project.apa > 0:
project.security_deposit = int(project.project_price) * int(project.apa) / 100
db.session.add(project)
db.session.commit()
db.session.refresh(project)
db.session.flush()
The error I get is
File "<project directory>utils/app_views.py", line 56, in decorated
return f(*args, **kwargs)
File "<project directory>views/admin/project.py", line 347, in admin_products_save_accommodation
db.session.refresh(project)
File "<project directory>models/project.py", line 297, in serialize
reviews, avg_rating = self.reviews
File "<project directory>models/project.py", line 269, in reviews
robj = db.session.query(ProjectReviews).filter_by(product_id=self.id).order_by('time_created').all()
File "<venv path>lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 237, in __get__
return self.impl.get(instance_state(instance), dict_)
File "<venv path>lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 578, in get
value = state._load_expired(state, passive)
File "<venv path>lib/python2.7/site-packages/sqlalchemy/orm/state.py", line 474, in _load_expired
self.manager.deferred_scalar_loader(self, toload)
File "<venv path>lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 664, in load_scalar_attributes
only_load_props=attribute_names)
File "<venv path>lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 219, in load_on_ident
return q.one()
File "<venv path>lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2693, in one
ret = list(self)
File "<venv path>lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2736, in __iter__
return self._execute_and_instances(context)
File "<venv path>lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2751, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File "<venv path>lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 914, in execute
return meth(self, multiparams, params)
File "<venv path>lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "<venv path>lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1010, in _execute_clauseelement
compiled_sql, distilled_params
File "<venv path>lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1161, in _execute_context
result = context.get_result_proxy()
File "<venv path>lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 474, in get_result_proxy
return _result.ResultProxy(self)
File "<venv path>lib/python2.7/site-packages/sqlalchemy/engine/result.py", line 495, in __init__
self._init_metadata()
File "<venv path>lib/python2.7/site-packages/sqlalchemy/engine/result.py", line 524, in _init_metadata
self._metadata = ResultMetaData(self, metadata)
File "<venv path>lib/python2.7/site-packages/sqlalchemy/engine/result.py", line 221, in __init__
in enumerate(result_columns)
File "<venv path>lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 764, in get_result_processor
return type_._cached_result_processor(self.dialect, coltype)
File "<venv path>lib/python2.7/site-packages/sqlalchemy/sql/type_api.py", line 392, in _cached_result_processor
d[coltype] = rp = d['impl'].result_processor(dialect, coltype)
File "<venv path>lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 361, in result_processor
"Unknown PG numeric type: %d" % coltype)
InvalidRequestError: Unknown PG numeric type: 25
I have tried many things, but failed.
I guess one of the fields in your table is a text and you are trying to retrieve it as a number.
postgres=# select * from pg_type where oid = 25;
-[ RECORD 1 ]--+---------
typname | text

blaze-odo error when trying to export an odo result to csv with MSSQL backend

I'm having an issue exporting some data from a MSSQL back-end to csv using blaze and odo.
The first thing that I do is create a blaze.data object that connects to the MSSQL db using a dns connection and pyodbc as the driver.
adjustment_statuses is a table in the database that the blaze.data object is connected to.
Then I use odo to take that result set and output it to a csv. When I output to a json format it works as expected. My hunch is that there is some issue with mssql support as an odo backend. Any odo devs have any insight here?
ez = bz.data(EZ_DB)
result = ez.adjustment_statuses
odo(result, os.path.join(ETL_STAGING_LOC, 'ez_adjustment.csv'))
Traceback (most recent call last):
File "<input>", line 25, in <module>
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\odo\odo.py", line 91, in odo
return into(target, source, **kwargs)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\multipledispatch\dispatcher.py", line 164, in __call__
return func(*args, **kwargs)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\blaze\interactive.py", line 406, in into
return into(a, result, **kwargs)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\multipledispatch\dispatcher.py", line 164, in __call__
return func(*args, **kwargs)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\odo\into.py", line 43, in wrapped
return f(*args, **kwargs)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\odo\into.py", line 143, in into_string
return into(a, b, dshape=dshape, **kwargs)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\multipledispatch\dispatcher.py", line 164, in __call__
return func(*args, **kwargs)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\odo\into.py", line 43, in wrapped
return f(*args, **kwargs)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\odo\into.py", line 131, in into_object
return append(target, source, dshape=dshape, **kwargs)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\multipledispatch\dispatcher.py", line 164, in __call__
return func(*args, **kwargs)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\odo\backends\sql.py", line 808, in append_table_to_csv
conn.execute(stmt)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\sqlalchemy\engine\base.py", line 945, in execute
return meth(self, multiparams, params)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\sqlalchemy\sql\elements.py", line 263, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\sqlalchemy\engine\base.py", line 1046, in _execute_clauseelement
if not self.schema_for_object.is_default else None)
File "<string>", line 1, in <lambda>
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\sqlalchemy\sql\elements.py", line 436, in compile
return self._compiler(dialect, bind=bind, **kw)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\sqlalchemy\sql\elements.py", line 442, in _compiler
return dialect.statement_compiler(dialect, self, **kw)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\sqlalchemy\dialects\mssql\base.py", line 1107, in __init__
super(MSSQLCompiler, self).__init__(*args, **kwargs)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\sqlalchemy\sql\compiler.py", line 435, in __init__
Compiled.__init__(self, dialect, statement, **kwargs)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\sqlalchemy\sql\compiler.py", line 216, in __init__
self.string = self.process(self.statement, **compile_kwargs)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\sqlalchemy\sql\compiler.py", line 242, in process
return obj._compiler_dispatch(self, **kwargs)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\sqlalchemy\ext\compiler.py", line 435, in <lambda>
lambda *arg, **kw: existing(*arg, **kw))
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\sqlalchemy\ext\compiler.py", line 474, in __call__
return fn(element, compiler, **kw)
File "C:\Users\jgenser\AppData\Local\Continuum\Anaconda2\envs\etl\lib\site-packages\sqlalchemy\ext\compiler.py", line 430, in _wrap_existing_dispatch
"compilation handler." % type(element))
CompileError: <class 'odo.backends.sql.CopyToCSV'> construct has no default compilation handler.

SQLAlchemy column with enum using PEP 435 compliant enum produces table creation error

I have an enum... defined very similarly to here.
When I try to create a table using the enum, as in the example, I get an error during table creation. It is a very vague error. Here is code that replicates the problem:
from sqlalchemy import Table, MetaData, Column, Enum, create_engine
import enum
class myEnum(enum.Enum):
one = 'one'
two = 'two'
three = 'three'
def main():
e = create_engine('sqlite:///:memory:')
e.echo = True
m = MetaData(bind = e)
t = Table('table', m, Column('my_enum', Enum(myEnum)))
t.create()
if __name__ == '__main__': main()
I get an AttributeError: replace when I run this code, with a seemingly useless stacktrace. I honestly don't even know where to begin debugging this and while I can conceive of a couple of possible workarounds, I am relatively new to SQLAlchemy so I'm not sure what the cleanest solution is. Surely basic enum support is a relatively simple expectation of a ORM framework?
Here is the full stack trace:
Traceback (most recent call last):
File "table_test.py", line 17, in <module>
if __name__ == '__main__': main()
File "table_test.py", line 16, in main
t.create()
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\schema.py", line 725, in create
checkfirst=checkfirst)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 1856, in _run_visitor
conn._run_visitor(visitorcallable, element, **kwargs)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 1481, in _run_visitor
**kwargs).traverse_single(element)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\visitors.py", line 121, in traverse_single
return meth(obj, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\ddl.py", line 764, in visit_table
include_foreign_key_constraints=include_foreign_key_constraints
File "C:\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 914, in execute
return meth(self, multiparams, params)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\ddl.py", line 68, in _execute_on_connection
return connection._execute_ddl(self, multiparams, params)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 962, in _execute_ddl
compiled = ddl.compile(dialect=dialect)
File "<string>", line 1, in <lambda>
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\elements.py", line 494, in compile
return self._compiler(dialect, bind=bind, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\ddl.py", line 26, in _compiler
return dialect.ddl_compiler(dialect, self, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 190, in __init__
self.string = self.process(self.statement, **compile_kwargs)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 213, in process
return obj._compiler_dispatch(self, **kwargs)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\visitors.py", line 81, in _compiler_dispatch
return meth(self, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 2173, in visit_create_table
create.include_foreign_key_constraints)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 2220, in create_table_constraints
for constraint in constraints
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 2218, in <genexpr>
p for p in
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 2226, in <genexpr>
not getattr(constraint, 'use_alter', False)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 213, in process
return obj._compiler_dispatch(self, **kwargs)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\visitors.py", line 93, in _compiler_dispatch
return meth(self, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 2369, in visit_check_constraint
literal_binds=True)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 213, in process
return obj._compiler_dispatch(self, **kwargs)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\visitors.py", line 81, in _compiler_dispatch
return meth(self, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 927, in visit_binary
return self._generate_generic_binary(binary, opstring, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 944, in _generate_generic_binary
binary.right._compiler_dispatch(self, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\visitors.py", line 81, in _compiler_dispatch
return meth(self, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 527, in visit_grouping
return "(" + grouping.element._compiler_dispatch(self, **kwargs) + ")"
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\visitors.py", line 81, in _compiler_dispatch
return meth(self, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 751, in visit_clauselist
for c in clauselist.clauses)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 748, in <genexpr>
s for s in
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 751, in <genexpr>
for c in clauselist.clauses)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\visitors.py", line 81, in _compiler_dispatch
return meth(self, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 1071, in visit_bindparam
bindparam, within_columns_clause=True, **kwargs)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 1103, in render_literal_bindparam
return self.render_literal_value(value, bindparam.type)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 1118, in render_literal_value
return processor(value)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\sqltypes.py", line 171, in process
value = value.replace("'", "''")
File "C:\Anaconda3\lib\enum.py", line 268, in __getattr__
raise AttributeError(name) from None
AttributeError: replace
PEP-435 enum support is being added in 1.1.
1.1.0b1 was recently released. You can upgrade to 1.1.0b1 but be wary of bugs. Based on release history I would say the stable version should be released in a month or two.
how to upgrade:
pip install 'sqlalchemy==1.1.0b3'

Categories

Resources