Created
January 15, 2017 21:42
-
-
Save mtask/2c808981ded27935b66cecb7e3c2f34b to your computer and use it in GitHub Desktop.
Connect pervasive DB Pyodbc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyodbc | |
db = pyodbc.connect('Driver={Pervasive ODBC Client Interface};ServerName=MyServer;dbq=@DB;') | |
cursor = db.cursor() | |
cursor.execute("SELECT Id FROM TABLE") | |
for row in cursor.fetchall(): | |
print row | |
db.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
para servicios restfull se pued usar flask
from flask import Flask, request
from flask_restful import Resource, Api
from sqlalchemy import create_engine
from json import dumps
from flask.ext.jsonpify import jsonify
import pyodbc
app = Flask(name)
api = Api(app)
class Areras(Resource):
def get(self):
conn = pyodbc.connect('Driver={Pervasive ODBC Client Interface};ServerName=127.0.0.1;dbq=demodata2;TCPPort=1583')
cursor = conn.cursor()
cursor.execute("SELECT * FROM Areas")
respuesta = {'areas': [[i[0], i[1]] for i in cursor.fetchall()]} # Fetches first column that is Employee ID
return respuesta
api.add_resource(Areras, '/areas')
if name == 'main':
app.run(port='5002')