MCPcopy Index your code
hub / github.com/dbcli/pgcli / create_db

Function create_db

tests/features/db_utils.py:4–25  ·  view source on GitHub ↗

Create test database. :param hostname: string :param username: string :param password: string :param dbname: string :param port: int :return:

(hostname="localhost", username=None, password=None, dbname=None, port=None)

Source from the content-addressed store, hash-verified

2
3
4def create_db(hostname="localhost", username=None, password=None, dbname=None, port=None):
5 """Create test database.
6
7 :param hostname: string
8 :param username: string
9 :param password: string
10 :param dbname: string
11 :param port: int
12 :return:
13
14 """
15 cn = create_cn(hostname, password, username, "postgres", port)
16
17 cn.autocommit = True
18 with cn.cursor() as cr:
19 cr.execute(f"drop database if exists {dbname}")
20 cr.execute(f"create database {dbname}")
21
22 cn.close()
23
24 cn = create_cn(hostname, password, username, dbname, port)
25 return cn
26
27
28def create_cn(hostname, password, username, dbname, port):

Callers

nothing calls this directly

Calls 2

create_cnFunction · 0.85
executeMethod · 0.45

Tested by

no test coverage detected