On Wed, Nov 22, 2017 at 2:55 PM, nahumcastro <[email protected]> wrote:
> Hello all
>
> I want to connect to an AS400 db2 server version 7.3 and put several csv
> files which where preprocessed with pandas, but seems that my db2 version is
> not supported.
>
> So far the only way I can connect is using the ODBC driver like
>
> conn = pyodbc.connect(driver='{iSeries Access ODBC
> Driver}',system='IP',uid='user',pwd='pass')
>
> The thing is. There is a way to generate raw generic sql inserts?
> like
> insert into conc ("Date","Cell","Amount","Carrier","ID","Status") values
> ('2017-09-04 21:25:45', ' 5555696647', ' 50', ' ATT', ' 555329', ' 0')
>
> so I can iterate all rows and insert using ODBC.
if you're not able to use the IBM db-sa package then you can't use a
SQLAlchemy dialect. Generating a simple insert like that is just a
matter of running the string with bound parameters using plain DBAPI:
cursor = conn.cursor()
cursor.executemany("insert into conc
("Date","Cell","Amount","Carrier","ID","Status") values (?, ?, ?, ?,
?)", [(<row>), (<row>), (<row>) ...])
this is straight DBAPI / pyodbc and has nothing to do with SQLAlchemy.
See https://www.python.org/dev/peps/pep-0249/ and
https://github.com/mkleehammer/pyodbc/wiki/Cursor#executemanysql-params.
>
>
> Thanks in advance.
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.