0

I'm using SQL Server with SQLAlchemy 1.3.18 library and thanks to fast_executemany = True, it's now faster than before.

I have to make the link with a Sybase Database. I've got the following error:

TypeError : Invalid argument(s) 'fast_executemany' sent to create_engine(),using configuration SybaseDialect_pyodbc/QueuePool/Engine.

This is going to be a problem for me because I want a quick connection and also quick writing on my db.But even if I erase these arguments from the method, I've got the following error :

sqlalchemy.exc.OperationnalError : (pyodbc.OperationnalError)

here is the code:

engine = sqlalchemy.create_engine(con['sql']['connexion_string'])

with con['sql']['connexion_string'] = "sybase+pyodbc://<user>:<password>@server_name/[db_name]driver=ODBC Driver 13 for SQL Server"

I think it comes from the driver (maybe I'm wrong), but I don't know which one take, and in the documentation, I've understood we have to use pyodbc so ODBC Drivers.

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
Neal Poidras
  • 35
  • 2
  • 7

3 Answers3

1

The internal sybase dialect does not support fast_executemany, but the external dialect does.

Note that you will need to use SAP's ODBC driver for ASE; FreeTDS ODBC won't work with fast_executemany.

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
0

So after many search, i've found something where it's workin for me.

yo have to writre like an odbc connexion:

    params = (
          "DRIVER = "+driver+";"\
          "SERVER = "+server+";"\
          "DATABASE = "+database+";"\
          "PORT = "+port+";"\
          "UID = "+user+";"\
          "PWD= "+password+";"

    params = urllib.parse.quote_plus(params) 

where params is your odbc connexion.

And then do this :

connexion_string = 'sybase+pyodbc:///?odbc_connect = %s'%params)

with this connexion string, you're able to do sqlalchemy.create_engine(connexion_string)

Neal Poidras
  • 35
  • 2
  • 7
0

For those in the future, this is how i fixed my problem on Windows:

get ODBC dsn path: start>control_panel>admin_tools>ODBC_Data_source(64-bit)> 2 options here: check the system DSN tab. you might see something named like 'prototype' with SQL Anywhere 17 Driver. or youll have to create your own DSN under File Dsn > Add > {select your dialect} > {Browse to save file path} > then click Finish. youll be prompted to fill in your Sql Anywhere info.... database name, Uid, PWD, etc... check out Chad Kenneedy's answer to setup custom ODBC Pyodbc error Data source name not found and no default driver specified paradox

  • make sure to test Dsn connection when you got it all figured out.

once thats done,

engine = create_engine("sybase+pyodbc://<DSN_username>:<DSN_password>@<DSN_file_name,eg_prototype>")

Pysnek313
  • 134
  • 14