Use pyodbc library to connect to an Hyperfilesql - python

Hi everyone this is my first question on this website.
So i'm working on a Python Project at work. And i have to connect my Python/Django application to an HyperfileSQL (Windev) database to write some information on the HyperFile tables.
I've installed pyodbc library to do the job. But when i was trying to make a connection in windows Cmd, it shows me this error:
pyodbc.connect('DRIVER={HyperFileSQL};SERVER=Mondev1;DATABASE=SP_MONTREAL;UI
D=admin;PWD=')
Traceback (most recent call last):
File "", line 1, in
pyodbc.Error: ('01000', "[01000] [Microsoft][ODBC Driver Manager] The
driver doesn't support the version of ODBC behavior that the application reques
ted (see SQLSetEnvAttr). (0) (SQLDriverConnect); [01S00] Invalid connection string attribute (0)")
I really don't understand why the connection failed. Anyone has any idea.
Note: Sorry about my poor english level i'm french :).

If you want to access hyperfile through odbc you need the driver odbc for hyperfilesql.
You need to buy it. Then install it and configure an odbc connection to your database. Here is the documentation :
http://doc.pcsoft.fr/fr-FR/?3044179
Then you will be able to access with python to your database through the odbc driver for hyperfilesql.
Hope it will help.

Related

Getting pyodbc to connect in Cloud Foundry

I am trying to get a python script to deploy to Cloud Foundry which uses pyobdc to connect to sql server and execute commands. My pyobdc connection statement looks like so:
warehouse_connection = pyodbc.connect(f'Driver={DRIVER}'
f';Server={SERVER}'
f';Database={DATABASE}'
f';UID={USERNAME}'
f';PWD={PASSWORD}'
';Trusted_Connection=no')
warehouse_cursor = warehouse_connection.cursor()
The driver I am using is ODBC Driver 17 for SQL Server and I have the odbcinst.ini file which looks like so:
[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/home/vcap/deps/0/apt/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.6.so.1.1
UsageCount=1
My script works fine on my local machine so I know the access account info is up to date and I have other scripts that use that driver which work fine, but when I try to deploy to Cloud Foundry I get the following error:
pyodbc.OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout
expired (0) (SQLDriverConnect)')
I tried changing the trusted connection variable, made sure my apt/environment was up to date, I am not sure what I am missing. Is there in issue with pyodbc in Cloud Foundry or am I getting something wrong?
Thanks.
In case anyone comes back an looks at this, it turns out all we needed to do was open up firewall access from that cloud foundry space and then it worked. Posted this a while ago and realized I should probably answer it.

Issues connecting to a DB2 server using Python. Possible issue identifying the driver

I had written code to connect to a DB2 server using Python that was working fine until my company had me upgrade the IBM DB2 Driver to 11.5. Now, its no longer working and I'm getting the following error message:
SQLCODE=-30082n: [IBM][CLI Driver] SQL30082N Security processing failed with reason "15" ("PROCESSING FAILURE"). SQLSTATE=08001
I verified that I have the right password. Also, I confirmed that I still have access to the Database by going through the ODBC Manager in Windows and testing a connection that way. I've checked several pages here on Stackoverflow and other sites and nothing seems to work. Most of the issues people are having on this site involve different error messages.
Here is the original code using the ibm_db module:
import ibm_db
import ibm_db_dbi
con = ibm_db_dbi.Connection(ibm_db.connect("ABC1011","rsmith","Passw123"))
When that stopped working i tried connecting using pyodbc as a connection:
import pyodbc
cnxn = pyodbc.connect('DRIVER={IBM DB2 ODBC DRIVER - DB2COPY2};Database=ABC1011;UID=rsmith; PWD=Passw123')
Again, I already verified in the ODBC Datasource Administrator (64-bit) that I am using the correct password, I have the correct database, and that I am using the correct driver's name. Does anyone know what else I may need to include to get a connection to work?
Thank you.

Error : connecting to Azure SQL DB from VM in Google cloud using pypyodbc

I am having issues connecting to an Azure database from a Virtual Machine running Ubuntu 16.04. This VM is in Google cloud. I get the following error
pypyodbc.Error: (u'IM002', u'[IM002] [unixODBC][Driver Manager]Data source
name
not found, and no default driver specified')
This code works fine locally on my PC in a Jupyter notebook. I have added the Google Cloud VM's IP address to the let it through the Azure firewall- so that doesn't appear to be the cause of the error. I have observed that I can replicate the original error message in Jupyter notebook if I change the driver "SQL Server Native Client" from 11.0 to 13.0
This all points to driver issues. A similar issue has been discussed here
With the problem being linked to "not defining that driver in the "/etc/odbcinst.ini" file."
My odbcinst.ini file contains the following information:
[ODBC Driver 13 for SQL Server]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.8.0
UsageCount=1
My odbc.ini file contains no information.
If I change my connection string in my code to "Driver={SQL Server Native Client 13.0" I get the same error. My other thought was to run with a version 11 of the driver. However there doesn't appear to be one for Ubuntu (only SUSE & RedHat Linux).I am new to this subject area- so feeling stuck. Any suggestions on a next logical step to resolve the connection issue.
Regards
Mike

Can't open database with pyodbc

I'm sure this is a stupidly simple issue but I just can't sort it out. I'm trying to open a local database with pyodbc but it won't let me.
The database and script are on the same path, there are no passwords. I only have one installation of Python on my system - Anaconda 3, and this is where pyodbc installed itself when I used PIP to install the Python 3.5, 64 bit whl file from Christoph Gohlke
import pyodbc
pyodbc.connect('Driver={SQL Server};Server=(local);Database=tblGrid.mdb;Trusted_Connection=yes;')
I get the following error:
pyodbc.Error: ('08001', '[08001] [Microsoft][ODBC SQL Server Driver][Shared Memory]SQL Server does not exist or access denied. (17) (SQLDriverConnect)')
Thanks
You need to use the Microsoft Access ODBC driver to open an *.mdb file.
Here is an example of connecting:
pyodbc.connect(
r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\some\path\tblGrid.mdb')

Connecting to PostgreSQL using pyodbc

I have a PostgreSQL running on localhost. I have psqlODBC Driver installed. Now when I try to connect to the server using pyodbc as:
import pyodbc
connection = pyodbc.connect("DRIVER={psqlOBDC};SERVER=localhost;DATABASE=weather;UID=postgres;PWD=password")
but I get this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pyodbc.Error: ('08001', '[08001] Already connected. (202) (SQLDriverConnect)')
Whats the problem?
Thanks.
Of course you must install ODBC driver. I don't know Mac, but in Windows there is ODBC Manager where you configure Data Sources. For PostgreSQL driver there is also "Test" button to check if connection can be established.
As fog noticed you can also use other technology to connect to PostgreSQL. If you can use Jython then you can use JDBC driver. There are also native drivers like psycopg, PyGreSQL and pg8000 (pure Python). Can you give them try?

Categories