MCPcopy Create free account
hub / github.com/OpenBMB/BMTools / resetConn

Method resetConn

bmtools/tools/database/utils/database.py:65–92  ·  view source on GitHub ↗
(self, timeout=-1)

Source from the content-addressed store, hash-verified

63 # self.schema = self.compute_table_schema()
64
65 def resetConn(self, timeout=-1):
66 if self.args.dbtype == 'mysql':
67 conn = pymysql.connect(
68 host=self.args.host,
69 user=self.args.user,
70 passwd=self.args.password,
71 database=self.args.dbname,
72 port=int(self.args.port),
73 charset='utf8',
74 connect_timeout=timeout,
75 read_timeout=timeout,
76 write_timeout=timeout)
77 else:
78 if timeout > 0:
79 conn = psycopg2.connect(database=self.args.dbname,
80 user=self.args.user,
81 password=self.args.password,
82 host=self.args.host,
83 port=self.args.port,
84 options='-c statement_timeout={}s'.format(timeout))
85 else:
86 conn = psycopg2.connect(database=self.args.dbname,
87 user=self.args.user,
88 password=self.args.password,
89 host=self.args.host,
90 port=self.args.port)
91
92 return conn
93 '''
94 def exec_fetch(self, statement, one=True):
95 cur = self.conn.cursor()

Callers 2

__init__Method · 0.95
execute_sqlMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected