mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-30 12:33:52 -06:00
2aeae06882
inputs. In order to do the proper quoting around the identifier, different type, and literal, we introduced respective functions qtIdent, qtTypeIdent, qtLiteral in psycopg2 driver. Also, introduced them as the Jinja's custom filter for using it directly inside the templates. Also, created an utility - generate_keywords.py in order to generate keyword lists from the latest PostgreSQL installation.
40 lines
853 B
Python
40 lines
853 B
Python
from flask import current_app
|
|
from .registry import DriverRegistry
|
|
|
|
|
|
def get_driver(type, app=None):
|
|
|
|
if app is not None:
|
|
DriverRegistry.load_drivers()
|
|
|
|
drivers = getattr(app or current_app, '_pgadmin_server_drivers', None)
|
|
|
|
if drivers is None or not isinstance(drivers, dict):
|
|
drivers = dict()
|
|
|
|
if type in drivers:
|
|
return drivers[type]
|
|
|
|
driver = DriverRegistry.create(type)
|
|
|
|
if driver is not None:
|
|
drivers[type] = driver
|
|
setattr(app or current_app, '_pgadmin_server_drivers', drivers)
|
|
|
|
return driver
|
|
|
|
def init_app(app):
|
|
drivers = dict()
|
|
|
|
setattr(app, '_pgadmin_server_drivers', drivers)
|
|
DriverRegistry.load_drivers()
|
|
|
|
return drivers
|
|
|
|
|
|
def ping():
|
|
drivers = getattr(current_app, '_pgadmin_server_drivers', None)
|
|
|
|
for type in drivers:
|
|
drivers[type].gc()
|