Questions tagged [python-db-api]

Questions about how to use the Python Database API Specification 2.0 -- PEP 249. Do include details about your database library

This API has been defined to encourage similarity between the Python modules that are used to access databases. By doing this, we hope to achieve a consistency leading to more easily understood modules, code that is generally more portable across databases, and a broader reach of database connectivity from Python.

See: https://www.python.org/dev/peps/pep-0249/

134 questions
0
votes
0 answers

how to pass a parameter to a sql script from python

I am trying to pass the parameter to the SQL script from python. below is the script I am trying; please let me know what I am doing wrong here... #!./bin/python _author_='Mohammed' import boto3 import cx_Oracle import sys con =…
Mohammed
  • 49
  • 1
  • 1
  • 6
0
votes
1 answer

INSERT INTO using Postgres on PYTHON DB-API

I'm trying to learn to add backend to a simple web app using postgreSQL and Python DB-API. When running the app, why do I get an error if the function get_posts() in forumdb. python uses c. execute ("SELECT * FROM posts ORDER BY time;) instead of…
day
  • 63
  • 1
  • 1
  • 2
0
votes
0 answers

connection and cursor in the same class in a DBAPI 2.0 implementation

I have a basic Python interface to a database, where what would be the "connection" class does the querying and retrieveing as well. I was wondering whether it would make sense to write a dummy cursor() function inside that class as: def…
Jay
  • 2,535
  • 3
  • 32
  • 44
0
votes
1 answer

Correct use of keys when joining tables in SQL

Currently learning data science with SQLite and Pandas. Working on a political contributions dataset. I'm wondering what is the purpose of WHERE contributors.candidate_id = candidates.id in the code below when joining two tables. Given my aim is to…
daytony
  • 398
  • 3
  • 9
0
votes
1 answer

Is there a lightweight Windows SDK core?

I need to compile the C++ source code of a version of Python DB API for IBM DB2: I am new to this and according to the readme, I need to first download Visual C++ 2003 (isnt it a too old version!?), Platform SDK lastest version (i think its…
babacim
  • 11
  • 1
  • 5
0
votes
0 answers

Error when connecting to sql using Python

I am using Python library pymssql to connect to a database. I have never used it before so the error might look trivial. from os import getenv import pymssql server = getenv("192.xxx.xxx.xx") user = getenv("john.constantine") password =…
John Constantine
  • 1,038
  • 4
  • 15
  • 43
0
votes
1 answer

Database API specification for Java

Is there a Database API specification for Java that is similar to what exists for Python (PEP249). I'd like to make an application that can be used to connect to databases, universally, without worrying about the database engine type.
Sailesh Sriram
  • 144
  • 2
  • 17
0
votes
1 answer

SQLite DB-API syntax issues Python 3.5

I have been searching through Stack Overflow as well as some other online research looking for the correct syntax to insert variables into my SQLite query. However, none of the 3 supported syntaxes have worked for my queries. I found that the three…
user5735326
0
votes
1 answer

Python DB-Api when to commit on multiple inserts/updates

I have a function which updates a single row in db. def update_one_row(conn, condition, value): with conn.cursor() as curr: curr.execute("""UPDATE persons p SET p.age=%s WHERE…
redacted
  • 3,789
  • 6
  • 25
  • 38
0
votes
2 answers

How do I specify Transaction Isolation Level for MS SQL backend in Sql Alchemy Python

How do I set transaction level READ UNCOMMITED for all queries done through a SQL Alchemy engine object? I set the isolation_level argument as notated here:…
michael g
  • 103
  • 1
  • 12
0
votes
0 answers

Instantiating SQLAlchemy engine from DBAPI connection object

I'm using SQLAlchemy from within Django, and I can access the thread-local database connection object in Django: from django.db import connection Given that connection object, can I use it to instantiate a SQLAlchemy engine? All of the documentation…
maxm
  • 5,161
  • 7
  • 30
  • 33
0
votes
1 answer

Python PYDBLITE - error adding records to pydblite

I have a Python script that uses the pydblite database library. when I run the code once the database is created and records added. if I run the code again an error is generated..Help Code db = Base('Storys.pdl') db.create('FeatureID', 'StoryID',…
Matt A
  • 47
  • 1
  • 7
0
votes
1 answer

WSGI how to print raw MYSQL output on the browser

The mysql output: b.query("select * from b where a='" + c + "' limit 1") result = b.store_result() d = result.fetch_row(0) the bottom of WSGI script: start_response('200 OK', [('content-type', 'text/html')]) return [d] apache error: …
user3880134
  • 63
  • 1
  • 1
  • 5
0
votes
0 answers

error: list index out of range. Python variable obtained using cur.fetchall() from an SQL query is not being read into another SQL query

there is a value I get from an SQL query which is stored with the name max_dateCS. This variable needs to be input into another SQL query. I am facing a problem doing that as it gives an error ' list index out of range'. query2 = """select…
0
votes
1 answer

How could one use Python's DBAPI to portably validate a database schema?

I'm writing a utility which I intend to be useable with at least three different database server backends (SQLite3, PostgreSQL, and MySQL). I'm not using an ORM (though I try a fork using SQLAlchemy after I've finished my prototype and become…
Jim Dennis
  • 17,054
  • 13
  • 68
  • 116
1 2 3
8
9