Is it possible to use pyodbc to read Paradox tables opened in Paradox gui?

I work in an environment with a very poorly managed old Paradox system database. (I'm not an administrator.) I messed around using pyobbc to interact with our tables, and it seems that the main functions work. Here is some (working) test code:

import pyodbc

LOCATION = "C:\test"

cnxn = pyodbc.connect(r"Driver={{Microsoft Paradox Driver (*.db )\}};DriverID=538;Fil=Paradox 5.X;DefaultDir={0};Dbq={0};CollatingSequence=ASCII;".format(LOCATION), autocommit=True, readonly=True)
cursor = cnxn.cursor()
cursor.execute("select last, first from test")
row = cursor.fetchone()
print row

The problem is that most of our important tables will open in someone’s Paradox interface at almost all times. I get this error whenever I try to make selectfrom one of these tables:

pyodbc.Error: ('HY000', "[HY000] [Microsoft][ODBC Paradox Driver] Could not lock 
table 'test'; currently in use by user '(unknown)' on machine '(unknown)'. (-1304) 
(SQLExecDirectW)")

This is obviously because pyodbc tries to lock the table when it is called cursor.execute(). This behavior makes sense because it cursor.execute()executes arbitrary SQL code and can modify the table.

, Paradox ( gui), , . , , .

pyodbc - , , select ? , , ?

, , .

0
3

, , , .

-, odbc Paradox, . , , .

, , .

, script , , , . , , .

- , , .

+1

, pyobdc (3.0.6) ,

Cursor.commit() Cursor.rollback(). .

readonly . True, SQLSetConnectAttr SQL_ATTR_ACCESS_MODE SQL_MODE_READ_ONLY. .

​​ SQL Server XML 4K.

, , readonly, .

, !

0

I just published a Python library for reading Paradox database files through the pxlib C library: https://github.com/mherrmann/pypxlib . This works at the file level, so you will also need to read the database regardless of who is currently receiving it. Since it does not synchronize read / write accesses, you need to be careful though!

0
source

Source: https://habr.com/ru/post/1608089/


All Articles