MCPcopy Create free account
hub / github.com/dbcli/mssql-cli / create_db

Function create_db

tests/features/db_utils.py:9–33  ·  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

7
8
9def create_db(hostname='localhost', username=None, password=None, dbname=None, port=None):
10 """Create test database.
11
12 :param hostname: string
13 :param username: string
14 :param password: string
15 :param dbname: string
16 :param port: int
17 :return:
18
19 """
20 cn = create_cn(hostname, password, username, 'postgres', port)
21
22 # ISOLATION_LEVEL_AUTOCOMMIT = 0
23 # Needed for DB creation.
24 cn.set_isolation_level(0)
25
26 with cn.cursor() as cr:
27 cr.execute('drop database if exists %s', (AsIs(dbname),))
28 cr.execute('create database %s', (AsIs(dbname),))
29
30 cn.close()
31
32 cn = create_cn(hostname, password, username, dbname, port)
33 return cn
34
35
36def create_cn(hostname, password, username, dbname, port):

Callers

nothing calls this directly

Calls 3

create_cnFunction · 0.85
executeMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected