-
Notifications
You must be signed in to change notification settings - Fork 7
/
createdb.py
executable file
·62 lines (53 loc) · 1.07 KB
/
createdb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env vpython3
import pytds
from t import username, userpass
class Main(object):
def __init__(self):
self.conn = pytds.connect(
dsn="127.0.0.1",
user=username,
password=userpass,
database="master",
autocommit=True,
)
def close(self):
self.conn.close()
def main(self):
sqls = (
"""\
DROP DATABASE IF EXISTS testing;
""",
"""\
CREATE DATABASE testing ON (
NAME = testing_dat,
FILENAME = '/var/opt/mssql/data/testing_mdf.mdf',
SIZE = 10,
FILEGROWTH = 5
) LOG ON (
NAME = testing_log,
FILENAME = '/var/opt/mssql/data/testing_ldf.ldf',
SIZE = 5MB,
FILEGROWTH = 5MB
)
""",
"""\
USE testing
""",
"""\
DROP SCHEMA IF EXISTS test_schema
""",
"""\
CREATE SCHEMA test_schema;
""",
)
c = self.conn.cursor()
for sql in sqls:
c.execute(sql)
c.close()
def main():
cls = Main()
try:
cls.main()
finally:
cls.close()
main()