consbio / pg-database-utils Goto Github PK
View Code? Open in Web Editor NEWA suite of utilities for PostgreSQL database queries and operations built on sqlalchemy
License: BSD 3-Clause "New" or "Revised" License
A suite of utilities for PostgreSQL database queries and operations built on sqlalchemy
License: BSD 3-Clause "New" or "Revised" License
It would be helpful to support connection options so that SSL connections could be made.
Here's an example of using connect_args
in SQLAlchemy:
db = create_engine('postgresql+pg8000://user:pass@hostname/dbname', connect_args={'sslmode':'require'})
On the Django side, these should come from the [OPTION](https://docs.djangoproject.com/en/3.0/ref/settings/#std:setting-OPTIONS)
param in the DATABASE
settings. For example:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': "db_name",
'USER': "db_username",
'PASSWORD': "db_password",
'HOST': "db_host",
'OPTIONS': {'sslmode': 'require'},
},
}
Not as simple as it may seem. Requires something like:
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.schema import DropTable
@compiles(DropTable, "postgresql")
def _compile_drop_table(element, compiler, **kwargs):
return compiler.visit_drop_table(element) + " CASCADE"
https://stackoverflow.com/questions/38678336/sqlalchemy-how-to-implement-drop-table-cascade
In order to use spatially-enabled Django models, the Django DATABASE
settings must use django.contrib.gis.db.backends.postgis
as the engine. However, pg-database-utils
then requests a postgis
dialect from SQLAlchemy, which fails with:
sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:postgis
Since this library is specific to postgresql databases, is it even necessary to get the engine/dialect from settings? Couldn't 'postgres` be hard-coded?
The most recent version of SQLAlchemy is 1.4.32. This library excludes 1.4 with it's dependency spec: sqlalchemy = "1.3.*"
. I'm not sure if there is code that would need to be changed to support 1.4, or if updating the dependency would be enough.
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.