Ugrás a fő tartalomra

Bejegyzések

#sql címkéjű bejegyzések megjelenítése

How can use Django, PostgreSQL, psycopg2, database parameters and multiple database schemas together?

When you start learning Django, first you started to use  ORM  and don't care about SQL. When you have found a bit more difficult issue and it is impossible to solve with it than you have to move to use Django  Manager.raw() . Then you will reach the point, you have to learn, how can you execute  custom SQL  directly. Without any magic. How can you use PostgreSQL in Django? Install  psycopg2  python module. How can you use multiple schemas in Django? You can declare in two places what kind of schema want to use. First, you can set up in settings.py and it can use with connections parameter. If you don't specify the connection's key, Django will be using the default database: Example  multiple database setup  in settings.py: DATABASES  = {     'default': {         ' ENGINE ': 'django.db.backends.postgresql',          ' OPTIONS ': {         ...