MCPcopy Create free account
hub / github.com/dbcli/mycli / create_db

Function create_db

test/features/db_utils.py:8–30  ·  view source on GitHub ↗

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

(hostname=DEFAULT_HOST, port=DEFAULT_PORT, username=None, password=None, dbname=None)

Source from the content-addressed store, hash-verified

6
7
8def create_db(hostname=DEFAULT_HOST, port=DEFAULT_PORT, username=None, password=None, dbname=None):
9 """Create test database.
10
11 :param hostname: string
12 :param port: int
13 :param username: string
14 :param password: string
15 :param dbname: string
16 :return:
17
18 """
19 cn = pymysql.connect(
20 host=hostname, port=port, user=username, password=password, charset=DEFAULT_CHARSET, cursorclass=pymysql.cursors.DictCursor
21 )
22
23 with cn.cursor() as cr:
24 cr.execute("drop database if exists " + dbname)
25 cr.execute("create database " + dbname)
26
27 cn.close()
28
29 cn = create_cn(hostname, port, password, username, dbname)
30 return cn
31
32
33def create_cn(hostname, port, password, username, dbname):

Callers 1

connectionFunction · 0.90

Calls 5

create_cnFunction · 0.85
connectMethod · 0.45
cursorMethod · 0.45
executeMethod · 0.45
closeMethod · 0.45

Tested by 1

connectionFunction · 0.72