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
1 answer

OpenTelemetry Python Instrumentation dbapi is not capturing the odbc database commands

I am trying to capture the database commands using Instrumentation DBapi, but i don't see anything to be reported to Jaeger. I am accessing database using pyodbc and pandas and i see while debugging that no exception is occurred and data returned…
kpo
  • 31
  • 3
0
votes
1 answer

Why do sqlite3 DB_API qmark and named style not work in "select where" queries?

Assuming I have a database with table users with a row: ID = 0, name = 'myName' I can get the ID value (assuming I'm connected) by using either: cursor.execute("""SELECT ID FROM users WHERE %s = %s""" % ('name',…
0
votes
1 answer

How can I use elasticsearch-dbapi with Open Distro for ElasticSearch, ignoring SSL certificates?

How can I use elasticsearch-dbapi with Open Distro for Elasticsearch, ignoring ssl certificates? I am using Open Distro for Elasticsearch 1.13.2, Python 3.7, elasticsearch client 7.12.1, sqlalchemy: 1.4.17, eland: 7.10.1b1 This works: from…
0
votes
1 answer

doubts about DB-API e SQLAlchemy

link da questão Briefly, I want to know what this "DB-API" mechanism is. Are there multiple DB-APIs (there are more than 1 DB-API)? Is it just a 'rules' document? have a source code? What is it for? Is psycopg2 an example of a DB-API or is it a…
user14522494
0
votes
1 answer

Python stops working when try to connect to SAP HANA

I'm trying to connect with SAP Hana using python on Anaconda. The SAP team has already given me the data to connect, but every time I try to run the code it simply loads for two seconds and then shows a pop up saying that "Python has stopped…
0
votes
1 answer

Floating point exception when using SQL when run but not when debugged

As part of my Python program, I have created a method which runs sql queries on a Db2 server. Here it is: def run_query(c, query, return_results=False): stmt = db.exec_immediate(c, query) if return_results: df = {} row =…
rhobro
  • 103
  • 1
  • 7
0
votes
1 answer

Why does this rollback function not work as expected

I am going to execute 2 sql queries and I want to put them in a transaction, if any query failed then call rollback(). The code is shown as following and 2 queries are str_trunction: truncate the table & str_insert: insert some rows codes: try: …
user2894829
  • 775
  • 1
  • 6
  • 26
0
votes
0 answers

share db connection pool across python processes

I have build an application (python3.6) which keeps checking a directory for incoming files and when there are files it spawns some python processes in order to work on those files.This work involves db calls and as of now there is no connection…
Varun Maurya
  • 337
  • 4
  • 18
0
votes
0 answers

DBAPI Error; SSL SYSCALL error: EOF detected when running docker image

I am trying to deploy a python app that filters my database on Redshift then inserts the aggregated rows into a new table. The insert works fine from the python script but when running the docker image it returns sqlalchemy.exc.OperationalError:…
0
votes
1 answer

How can I run multiple SQL statements in a query in python?

I'm implementing migrations for my program, and I need some way to run multiple statements in a query. I have a dict of migrations: MIGRATIONS = { "test": ("-- apply", "-- revert", "does nothing") } (first tuple element is the…
SoniEx2
  • 1,864
  • 3
  • 27
  • 40
0
votes
1 answer

Find databasetype ( SQlite, Mysql, PostgreSQL ) from dbapi in python

I need to find out what kind of database I am working against based on data from an dbapi cursor instance. Have not found any clues on how to do this in the dbapi docs. Can it be done?
Weholt
  • 1,889
  • 5
  • 22
  • 35
0
votes
2 answers

How to use pyhive sqlalchemy to connect to Databricks clusters?

I'm using following code to connect to Databricks clusters. But got thrift.transport.TTransport.TTransportException: TSocket read 0 bytes . I think there is some error of the my_url in create_engine. from sqlalchemy.engine import…
dlwlrma
  • 808
  • 2
  • 10
  • 21
0
votes
1 answer

syntax error when using substring in a join expression with PostgreSQL

I'm working with postgresql using the Python DB API. The substring expression I'm using works fine when on its own, but when I put it in the context of a join command I get a syntax error, and I can't find a solution to this in any tutorial or…
topplethepat
  • 531
  • 6
  • 23
0
votes
1 answer

Does Ruby or Rails have an equivalent of pandas.read_sql?

So in Python, I am used to using something like pd.read_sql(sql_query, connection_object) in order to grab data from a remote database. But when forming a similar connection object in Ruby: require 'pg' @connect_obj = PG.connect(:host => host,…
Flair
  • 2,609
  • 1
  • 29
  • 41
0
votes
0 answers

Python DBAPI cursor fetchmany in a generator is closed too early

import dbapi2 conn = dbapi2.connect("db", autocommit=True) def fetch_generator(): cursor = conn.cursor() for res in cursor.execute('select * from table'): yield res def generator_1(): for x in fetch_generator(): yield…
Jason
  • 1,974
  • 24
  • 19
1 2 3
8 9