# coding=utf-8
import MySQLdb
import csv
import random
import pymysql
import pandas as pd
import MySQLdb as mdb
import sys
import time
import os
import numpy as np
import time
import gzip
import datetime
class BlobDataTestor:
def __init__ (self):
self.conn = MySQLdb.connect(host='***',user='***',passwd='***',db='***')
def __del__ (self):
try:
self.conn.close()
except :
pass
def closedb(self):
self.conn.close()
def setup(self):
cursor = self.conn.cursor()
def testGetuserid(self , p_remark):
#cursor = self.conn.cursor()
sql = "select tablename from PATIENT where id='%s'" % (p_remark)
print(sql)
cursor = self.conn.cursor()
cursor.execute( sql)
data=cursor.fetchall()
print("-------------------",data[0][0])
return data[0][0]
def main():
test = BlobDataTestor()
test.setup()
test.testGetuserid("lw1")
test.closedb()
if __name__ == "__main__":
print("start")
print(sys.argv)
main()
python连接mysql
于 2022-04-18 11:33:06 首次发布