Began to learn Python 2.7 + PostgreSQL 9.6.1. Python already has some experience, but I don’t have any experience with PostgreSQL. (Windows 8)
There is a database name_db , which I create with the following code:
#!/usr/bin/python # -*- coding: utf-8 -*- from psycopg2 import connect import sys from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT con = None con = connect(user='postgres', password='poilk', port=5432) dbname = "name_db" con.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) cur = con.cursor() cur.execute('CREATE DATABASE ' + dbname) cur.close() con.close() Questions:
- Where is the "name_db"? In the folder with the project it is not. Search engine in Windows also does not know such files. (... PostgreSQL \ 9.6 \ data - the path to the database when installing PostgreSQL)
- How to change the path to save the database file in the folder with the project
.../db/?