Pervasive 8 and Python

Is it possible to access a Pervasive 8 (not Pervasive SQL) database from python?

+2


source to share


2 answers


I'm not familiar with Pervasive, but from a quick search on the internet it seems that people are using some kind of ODBC driver to access Pervasive 8.



ODBC databases can be used from python on Windows using PyODBC: http://code.google.com/p/pyodbc/

+2


source


Yes, you can. here is the working code



import os
import sys
import pyodbc

def main():
   conn_str = 'Driver={Pervasive ODBC Interface};server=localhost;DBQ=DATABASENAME'
   db = pyodbc.connect(conn_str)
   c = db.cursor()
   c.execute("SELECT COUNT(*) FROM TABLENAME")
   row = c.fetchone()
   if row:
      print(row)
   return 0
if __name__ == "__main__":
   sys.exit(main())

      

0


source







All Articles