mirror of
https://github.com/hequan2017/seal.git
synced 2026-02-04 10:43:26 +08:00
26 lines
682 B
Python
26 lines
682 B
Python
#!/usr/bin/env python
|
|
# -*- coding:utf-8 -*-
|
|
|
|
import pymysql
|
|
import prettytable as pt
|
|
tb = pt.PrettyTable()
|
|
|
|
sql = '''/*--user=root;--password=123456;--host=192.168.100.90;--check=0;--port=3306;--execute=1;--backup=1;*/
|
|
inception_magic_start;
|
|
use go;
|
|
create table t1(id int primary key,c1 int,c2 int );
|
|
insert into t1(id,c1,c2) values(1,1,1);
|
|
inception_magic_commit;'''
|
|
|
|
conn = pymysql.connect(host='127.0.0.1', user='', passwd='',
|
|
db='', port=4000, charset="utf8mb4")
|
|
cur = conn.cursor()
|
|
ret = cur.execute(sql)
|
|
result = cur.fetchall()
|
|
cur.close()
|
|
conn.close()
|
|
|
|
tb.field_names = [i[0] for i in cur.description]
|
|
for row in result:
|
|
tb.add_row(row)
|
|
print(tb) |