Skip to content

Commit

Permalink
Fixed module import method.
Browse files Browse the repository at this point in the history
  • Loading branch information
PoshoDev committed Oct 27, 2021
1 parent bb7b7df commit 73a23fb
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 55 deletions.
54 changes: 53 additions & 1 deletion loaf/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,53 @@
from general import bake
import pymysql, datetime, socket

host_ = socket.gethostbyname(socket.gethostname())
port_ = 80 # Default XAMPP Apache server port.
user_ = "root"
pasw_ = ""
db_ = None
creds_ = ""

# Make this differently, for the love of god!
def bake(host=host_, port=port_, user=user_, pasw=pasw_, db=db_, creds=creds_):
global host_, port_, user_, pasw_, db_, creds_
if host != "": host_=host
if port != "": port_=port
if user != "": user_=user
if pasw != "": pasw_=pasw
if db != "": db_=db
if creds != "": creds_=creds

# A query.
def query(query):
conn = pymysql.connect(host=host_, port=port_, user=user_, passwd=pasw_, db=db_)
conn_object = conn.cursor()
conn_object.execute(query)
str = conn_object.fetchall()
conn.commit()
conn.close()
return str

# Call a stored procedure.
def call(func, *args):
call = "CALL " + func + "("
if len(args) > 0:
for i in range(len(args)):
call += (str(args[i]) if type(args[i])==type(1) else parseNull(args[i])) + (", " if i<len(args)-1 else ");")
else: call += ");"
q = query(call)
return q[0][0] if len(q)==1 else q

# Quick query.
def all(table):
return query(f"SELECT * from {table};")

def getToday():
dat = datetime.date.today() + datetime.timedelta(days=1)
return dat.strftime("%Y-%m-%d")

def getTomorrow():
dat = datetime.date.today() + datetime.timedelta(days=1)
return dat.strftime("%Y-%m-%d")

def parseNull(val):
return "NULL" if val in ["", "NULL"] else "'"+val+"'"
53 changes: 0 additions & 53 deletions loaf/general.py

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

VERSION = '0.1.8'
VERSION = '0.1.10'
DESCRIPTION = 'Effortlessly access your MySQL server and procedures, plus some other utilities!'
with open('README.md', encoding="utf8") as f:
LONG_DESCRIPTION = f.read()
Expand Down

0 comments on commit 73a23fb

Please sign in to comment.