I'm using python 2.7 and I want to connect to a DB2 database and insert data into it. Here is what I did so far :
import sqlalchemy
from sqlalchemy import *
import ibm_db_sa
db2 = sqlalchemy.create_engine('ibm_db_sa://user:pswd@localhost:50001/prm')
metadata = MetaData()
users = Table('users', metadata,
Column('user_id', Integer, primary_key = True),
Column('user_name', String(16), nullable = False),
Column('email_address', String(60), key='email'),
Column('password', String(20), nullable = False)
)
metadata.bind = db2
metadata.create_all()
users_table = Table('users', metadata, autoload=True, autoload_with=db2)
users_table
The problem is when I execute the code above I get this the following error :
ProgrammingError: (ProgrammingError) ibm_db_dbi::ProgrammingError: [IBM][CLI Driver]
SQL1042C An unexpected system error occurred. SQLSTATE=58004\r SQLCODE=-1042 None None
Can anyone help me to figure this out ?