kerol / django-conn-pool Goto Github PK
View Code? Open in Web Editor NEWMySQL Connection Pooling with Django and SQLAlchemy
License: MIT License
MySQL Connection Pooling with Django and SQLAlchemy
License: MIT License
When doing tests with pytest I have this error:
../../.venvs/mb-back/lib/python3.6/site-packages/django/test/utils.py:174: in setup_databases
serialize=connection.settings_dict.get('TEST', {}).get('SERIALIZE', True),
../../.venvs/mb-back/lib/python3.6/site-packages/django/db/backends/base/creation.py:58: in create_test_db
self._create_test_db(verbosity, autoclobber, keepdb)
../../.venvs/mb-back/lib/python3.6/site-packages/django/db/backends/base/creation.py:168: in _create_test_db
with self._nodb_connection.cursor() as cursor:
../../.venvs/mb-back/lib/python3.6/site-packages/django/db/backends/base/base.py:256: in cursor
return self._cursor()
../../.venvs/mb-back/lib/python3.6/site-packages/django/db/backends/base/base.py:233: in _cursor
self.ensure_connection()
../../.venvs/mb-back/lib/python3.6/site-packages/django/db/backends/base/base.py:217: in ensure_connection
self.connect()
../../.venvs/mb-back/lib/python3.6/site-packages/django/db/backends/base/base.py:195: in connect
self.connection = self.get_new_connection(conn_params)
../../.venvs/mb-back/lib/python3.6/site-packages/django_conn_pool/mysql/base.py:64: in get_new_connection
alias = self._get_alias_by_params(conn_params)
../../.venvs/mb-back/lib/python3.6/site-packages/django_conn_pool/mysql/base.py:80: in _get_alias_by_params
target_str = ''.join([str(conn_params[_]) for _ in ['host', 'port', 'db', 'user', 'passwd']])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.0 = <tuple_iterator object at 0x7f35bffafac8>
> target_str = ''.join([str(conn_params[_]) for _ in ['host', 'port', 'db', 'user', 'passwd']])
E KeyError: 'db'
../../.venvs/mb-back/lib/python3.6/site-packages/django_conn_pool/mysql/base.py:80: KeyError
django==2.2.8
pytest==3.7.0
It works if I manually returning the "default" alias in django_conn_pool/mysql/base.py:80
. I am not very deep into the internal functioning of Django but I will try to help. Setting TEST NAME param doesn't help.
Also manually setting another engine for tests solves this but I think it should be resolved in this library. This is the solution I used. In DATABASES settings:
'ENGINE': 'django_conn_pool.mysql' if not DEBUG else 'django.db.backends.mysql'
1062, "Duplicate entry '1' for key 'PRIMARY'"
I am using this engine for both my master and slave db configurations in setting.py, but whenever I try to execute a raw query via connections, the query is still being hit on master db.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.