Oleg Deribas wrote:
> Hello,
>
>
> I'm trying to investigate possibility to use SQLAlchemy with Firebird
> SQL. And I've wrote this simple script following tutorial:
>
> ---------------------------------------------------------------------
> from sqlalchemy import *
>
> db = create_engine('firebird://SYSDBA:[EMAIL PROTECTED]/employee')
>
> metadata = BoundMetaData(db)
> metadata.engine.echo = True
>
> try:
> # Drop users table if it exists
> users_table = Table('users', metadata, autoload=True)
> users_table.drop()
> del(users_table)
> except:
> pass
>
> users_table = Table('users', metadata,
> Column('user_id', Integer, primary_key=True),
> Column('user_name', String(40)),
> Column('passwd', String(10)),
> redefine=True
> )
>
> users_table.create()
> i = users_table.insert()
> print i
> ---------------------------------------------------------------------
>
> And it gives me this:
> AttributeError: 'NoneType' object has no attribute 'has_key'
>
> My config:
> win2k, python 2.4, SQLAlchemy 0.2.6, kinterbasdb 3.2rc1, firebird 2.0rc3
>
Firebird needs exclusive access for DDL.
Normally you don't do DDL and DML in the same script.
Try creating the needed table, commit it and drop the connection.
Than create a new connection and do your data inserts.
At least, that's how i am doing it.
It works!
Uwe
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users