Questions tagged [python]
Python is a powerful and ubiquitous language. When using a Python variant or library (e.g. Pandas, SQLAlchemy, pg8000, psycopg2), please include it in the tags. Questions using this tag should restrict themselves to interactions directly with the database tier. General python scripting questions should be directed to [StackOverflow](https://stackoverflow.com/questions/tagged/python)
                276 questions
            
            
            
                0
            
            votes
        
        
            
                0
            
            answers
        
        
            
                33
            
            views
        
        
            
        Using single Session vs multiple sessions for each request in FastAPI
                    I am building a fastapi project following a controller, manager and repo layers. My db connection and session is initialized and injected into each controller on the first request. It means my each ...
                
            
       
        
            
                0
            
            votes
        
        
            
                0
            
            answers
        
        
            
                36
            
            views
        
        
            
            
        Prepared statements not working with Psycopg3 + PgBouncer (transaction pooling)
                    I'm running into unexpected behavior when trying to use prepared statements with TimescaleDB through PgBouncer in transaction pooling mode.
According to the Psycopg3 docs on prepared statements and ...
                
            
       
        
            
                2
            
            votes
        
        
            
                1
            
            answer
        
        
            
                90
            
            views
        
        
            
            
        How to correctly store and retrieve timezone-aware timestamps in GridDB Cloud using Python without losing offset information?
                    I’m using GridDB Cloud with the Python client griddb_python and storing IoT event timestamps that are timezone-aware (e.g., UTC+05:30).
Example row insert:
import griddb_python as griddb
import ...
                
            
       
        
            
                0
            
            votes
        
        
            
                1
            
            answer
        
        
            
                66
            
            views
        
        
            
            
        How to resolve an access issue while running SQL Server Agent to execute a Python?
                    I am trying to use SQL Server Agent to execute a Python file.
I am executing Python file using a Powershell script.
When I ran the SQL Server Agent job, error message says:
Message
Executed as user: ...
                
            
       
        
            
                2
            
            votes
        
        
            
                1
            
            answer
        
        
            
                72
            
            views
        
        
            
            
            
        How to group by with similar group_name in sql
                    How can I perform a
 GROUP BY
in SQL when the group_name values are similar but not exactly the same?
In my dataset, the group_name values may differ slightly (e.g., "Apple Inc.", "...
                
            
       
        
            
                2
            
            votes
        
        
            
                1
            
            answer
        
        
            
                67
            
            views
        
        
            
            
        improve the implementation of worldquant 101 alpha factors using numpy
                    I was trying to implement 101 quant trading factors that was published by WorldQuant (https://arxiv.org/pdf/1601.00991.pdf).
A typical factor is about processing stocks' price and volume information ...
                
            
       
        
            
                1
            
            vote
        
        
            
                3
            
            answers
        
        
            
                244
            
            views
        
        
            
            
            
        ERROR: invalid byte sequence for encoding "UTF8": 0xdc 0x36
                    When running a \copy (either pgadmin or aws_s3.table_import_from_s3) of a 1.6GB file into an AWS Aurora Postgres-compatible database, I'm getting the following error:
ERROR:  invalid byte sequence for ...
                
            
       
        
            
                0
            
            votes
        
        
            
                0
            
            answers
        
        
            
                68
            
            views
        
        
            
            
        How can I replicate data from a SQL Server VM in Azure to avoid recovery mode for reporting?
                    Currently, I'm using SQL Server on an Azure VM (DB B) to read from Power BI. DB B updates via log shipping from a primary SQL Server (DB A) and it locks me out from reading DB B two times an hour. I'...
                
            
       
        
            
                0
            
            votes
        
        
            
                1
            
            answer
        
        
            
                50
            
            views
        
        
            
        Managing Feature Deletions and Triggers in SQLite with Python Integration (QGIS)
                    I am working with Spatialite layers on QGIS for a project that is also used by colleagues who are unfamiliar with SQLite, meaning they won’t be running SQLite queries themselves.
The issue I’m facing ...
                
            
       
        
            
                0
            
            votes
        
        
            
                1
            
            answer
        
        
            
                282
            
            views
        
        
            
            
            
        Execute Python with Powershell in SQL Server 2019
                    I have been using SQL Server 2016's SQL Server Agent with bottom setting and script for last 3+ years. It was/is working fine.
But, now, I am migrating everything to SQL Server 2019, but the same ...
                
            
       
        
            
                0
            
            votes
        
        
            
                0
            
            answers
        
        
            
                73
            
            views
        
        
            
        postgressql connection issues via python
                    I have a python code that runs simulations and writes the results to Postgres table. I have several machines on the network, But only the first one runs without any problems. other machines have ...
                
            
       
        
            
                0
            
            votes
        
        
            
                1
            
            answer
        
        
            
                129
            
            views
        
        
            
            
            
        After upgrade Postgres python is the same version
                    I upgraded my postgres from 13.5 to 16.2 version (and the RHEL from 7.5 to 8.9).
The problem is, python was not upgraded.
I created procedure pyver():
CREATE OR REPLACE FUNCTION pyver ()
RETURNS TEXT
...
                
            
       
        
            
                1
            
            vote
        
        
            
                0
            
            answers
        
        
            
                66
            
            views
        
        
            
        PostGres DB is read only in pgAdmin despite successful migration into it
                    I have an old MS Access Database that I want to migrate to a Postgres Db hosted in a Docker environment on a Windows Server.
I want to keep the MS Access Frontend, because it has some Forms and ...
                
            
       
        
            
                0
            
            votes
        
        
            
                0
            
            answers
        
        
            
                319
            
            views
        
        
            
            
        Frequent MySql client error "got an error writing communication packets"
                    I have several different Linux servers running MySQL 8.0.x instances (ranging from 8.0.23 to 8.0.33).
I occasionally get "error writing communication packets" from clients when connecting to ...
                
            
       
        
            
                1
            
            vote
        
        
            
                0
            
            answers
        
        
            
                701
            
            views
        
        
            
        Railway - problems with connecting to postgres in production
                    Django worked perfectly locally, but had errors in production (I was using the same postgres DB and configuration).
Django server, hosted on Railway gave me this:
Newtorking tab in Postgres settings ...
                
            
       
         
        