database-connection

Odoo: psycopg2.OperationalError: FATAL: too many connections for role "p_my_oerp_master_11234451"

Odoo: psycopg2.OperationalError: FATAL: too many connections for role "p_my_oerp_master_11234451" Question: Since Today (the 30 of September), using Odoo v13 on Odoo.sh, after logging in my odoo account as "ADMIN" or another odoo user, i got this error every minute and all "Odoo internal Users" get disconnected from their session every couple of minutes: psycopg2.OperationalError: FATAL: …

Total answers: 2

Best practices for persistent database connections in Python when using Flask

Best practices for persistent database connections in Python when using Flask Question: My question is about the recommended approach for handling database connections when using Flask in a production environment or other environment where performance is a concern. In Flask, the g object is available for storing things, and open database connections can be placed …

Total answers: 1

Python Postgres psycopg2 ThreadedConnectionPool exhausted

Python Postgres psycopg2 ThreadedConnectionPool exhausted Question: I have looked into several ‘too many clients’ related topic here but still can’t solve my problem, so I have to ask this again, for me specific case. Basically, I set up my local Postgres server and need to do tens of thousands of queries, so I used the …

Total answers: 4

how to parse mysql database name from database_url

how to parse mysql database name from database_url Question: DATABASE_URL- MYSQL://username:password@host:port/database_name Error: database_name has no attributes. if ‘DATABASE_URL’ in os.environ: url = urlparse(os.getenv[‘DATABASE_URL’]) g[‘db’] = mysql.connector.connect(user=url.username,password=url.password, host=url.hostname ,port=url.port,path=url.path[1:]) Asked By: guri || Source Answers: First of all, url.host would result into: AttributeError: ‘ParseResult’ object has no attribute ‘host’ use url.hostname instead. To get the database_name …

Total answers: 4

sqlalchemy mysql connections not closing on flask api

sqlalchemy mysql connections not closing on flask api Question: I have an API I have written in flask. It uses sqlalchemy to deal with a MySQL database. I don’t use flask-sqlalchemy, because I don’t like how the module forces you into a certain pattern for declaring the model. I’m having a problem in which my …

Total answers: 1

Necessity of explicit cursor.close()

Necessity of explicit cursor.close() Question: From time to time, I’m executing raw queries using connection.cursor() instead of using ORM (since it is definitely not a silver bullet). I’ve noticed that in several places I don’t call explicit cursor.close() after I’m done with database. So far, this hasn’t result into any errors, or performance issues. I’m …

Total answers: 5

ImportError: No localization support for language 'eng' in python

ImportError: No localization support for language 'eng' in python Question: I am getting ImportError: No localization support for language ‘eng’ when using MySQL Connector in Python. My Traceback is as below. Traceback (most recent call last): File “DB_Module.py”, line 151, in QueryDatabase File “\shareappModulesmysqlconnector__init__.py”, line 44, in Connect File “\shareappModulesmysqlconnectorconnection.py”, line 106, in __init__ File …

Total answers: 3

What's causing 'unable to connect to data source' for pyodbc?

What's causing 'unable to connect to data source' for pyodbc? Question: I’m trying to connect to an MSSQL database from python on Linux (SLES). I have installed pyodbc and Free TDS. From the command line: tsql -H server -p 1433 -U username -P password Connects to the server without a problem, however, from Python: import …

Total answers: 13

What if I don't close the database connection in Python SQLite

What if I don't close the database connection in Python SQLite Question: I am doing something like this… conn = sqlite3.connect(db_filename) with conn: cur = conn.cursor() cur.execute( … ) with automatically commits the changes. But the docs say nothing about closing the connection. Actually I can use conn in later statements (which I have tested). …

Total answers: 6