Anda di halaman 1dari 1

import pymysql

#import MySQLdb

class conn:
def __init__(self):

self.connection=pymysql.Connect(host="localhost",user="root",password="",db="fs",po
rt=3306)
# self.connection = MySQLdb.Connect(host="localhost", user="root",
password="", db="fs", port=3306)

self.cu=self.connection.cursor()

def nonreturn(self,a):
self.cu.execute(a)

self.connection.commit()
return self.cu.lastrowid
def mid(self,a):
self.cu.execute(a)
self.f=self.cu.fetchone()
# print(self.f,"ss")
if self.f[0] is not None:
self.id=self.f[0]+1
else:
self.id = 1

return (self.id)
def selectall(self,a):
self.cu.execute(a)
res=self.cu.fetchall()
return (res)
def selectone(self,a):
self.cu.execute(a)
res=self.cu.fetchone()
return (res)

def jsonselectall(self, a):


self.cu.execute(a)
res = self.cu.fetchall()
return (res,self.cu)

Anda mungkin juga menyukai