python - SQLalchemy: alembic bulk_insert() fails -


before flag duplicate:

i did take @ question/answer, , did suggests, when add code:

permslookup = sa.table('permslookup',     sa.column('perms_lookup_id', primary_key=true),     sa.column('name', sa.unicode(40), index=true),     sa.column('description', sa.text),     sa.column('value', sa.numeric(10, 2)),     sa.column('ttype', sa.pickletype(), index=true),     sa.column('permission', sa.unicode(40), index=true),     sa.column('options', sa.pickletype())     ) 

and run alembic upgrade head, following error:

attributeerror: neither 'column' object nor 'comparator' object has attribute 'schema' 

when examine full stack trace, notice causing error:

sa.column('options', sa.pickletype()) 

this last line of above code... how can resolve this? have not clue how solve it... of kind appreciated.

here data want insert:

op.bulk_insert('permslookup',     [         {             'id': 1,             'name': 'accounts',             'description': """ have permission transactions """,             'value': 1,             'ttype': ['cash', 'loan', 'mgmt', 'deposit', 'adjustments'],             'permission': 'accounts',             'options': none         },         {             'id': 2,             'name': 'agent_manage',             'description': """ have permission cash, cash, loan , management discretion transactions """,             'value': 2,             'ttype': ['cash', 'loan', 'mgmt'],             'permission': 'agent_manage',             'options': none         },         {             'id': 3,             'name': 'corrections',             'description': """ have permission cash, loan , adjustments transactions """,             'value': 3,             'ttype': ['cash', 'loan', 'adjustments'],             'permission': 'corrections',             'options': none         },         {             'id': 4,             'name': 'cashup',             'description': """ have permission cash , loan transactions """,             'value': 4,             'ttype': ['cash', 'loan'],             'permission': 'cashup',             'options': none         },      ] ) 

the original error when trying run bulk_insert is:

attributeerror: 'str' object has no attribute '_autoincrement_column' 

for error #1, not enough information. need stack trace.

for #2, bulk_insert() receives table object, not string name, argument.

see http://alembic.readthedocs.org/en/latest/ops.html#alembic.operations.operations.bulk_insert:

from alembic import op datetime import date sqlalchemy.sql import table, column sqlalchemy import string, integer, date  # create ad-hoc table use insert statement. accounts_table = table('account',     column('id', integer),     column('name', string),     column('create_date', date) )  op.bulk_insert(accounts_table,     [         {'id':1, 'name':'john smith',                 'create_date':date(2010, 10, 5)},         {'id':2, 'name':'ed williams',                 'create_date':date(2007, 5, 27)},         {'id':3, 'name':'wendy jones',                 'create_date':date(2008, 8, 15)},     ] ) 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -