Skip to content

Commit 1bb6fd5

Browse files
committed
1.2.6: Fixed ORM bugs (still not sure about the select func
1 parent 00c2eb8 commit 1bb6fd5

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

Lemon/orm/DBManager.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ def __enter__(self):
1414
return self
1515

1616
def commit(operation):
17-
def wrapper(self, tablename, fields):
18-
operation(self, tablename, fields)
17+
def wrapper(self, *args, **kwargs):
18+
operation(self, *args, **kwargs)
1919
self.connection.commit()
20-
print(f"{datetime.datetime.now()}: Commit is successful!!")
20+
print("Lemon.orm: Commit Successful")
2121
return wrapper
2222

2323
@commit
@@ -50,25 +50,25 @@ def __exit__(self, type, value, traceback):
5050
class SqliteManager():
5151
def __init__(self, filename):
5252
self.filename = filename
53-
self.connection = sql3.connect(self.filename)
54-
self.cursor = sql3.connect(filename).cursor()
53+
self.connection = sql3.connect(self.filename, check_same_thread=False)
54+
self.cursor = self.connection.cursor()
5555

5656
def __enter__(self):
5757
return self
5858

5959
def commit(operation):
60-
def wrapper(self, tablename, fields):
61-
operation(self, tablename, fields)
60+
def wrapper(self, *args, **kwargs):
61+
operation(self, *args, **kwargs)
6262
self.connection.commit()
63-
print(f"{datetime.datetime.now()}: Commit is successful!!")
63+
print("Lemon.orm: Commit Successful")
6464
return wrapper
6565

6666
@commit
6767
def create_table(self, tablename, columns):
6868
columns = list(columns)
6969
columns = " text, ".join(columns) +" text"
7070
drop_command = f"DROP TABLE IF EXISTS {tablename}"
71-
create_command = f"CREATE TABLE {tablename} ({columns})"
71+
create_command = f"CREATE TABLE {tablename} ({columns});"
7272
try:
7373
self.cursor.execute(drop_command)
7474
self.cursor.execute(create_command)
@@ -81,7 +81,7 @@ def create_table(self, tablename, columns):
8181
def insert(self, tablename, columns, values):
8282
column = ", ".join(columns) if len(columns) > 1 else columns
8383
value = ", ".join(values) if len(values) > 1 else values
84-
command = f"INSERT INTO {tablename} ({column}) VALUES ({value})"
84+
command = f"INSERT INTO {tablename} ({column}) VALUES ({value});"
8585
try:
8686
self.cursor.execute(command)
8787
except sql3.Error as er:
@@ -90,7 +90,7 @@ def insert(self, tablename, columns, values):
9090
@commit
9191
def select(self, tablename, columns):
9292
columns = ", ".join(columns) if len(columns) > 1 else columns
93-
command = f"SELECT {columns} FROM {tablename}"
93+
command = f"SELECT {columns} FROM {tablename};"
9494
try:
9595
self.cursor.execute(command)
9696
except sql3.Error as er:
@@ -101,7 +101,7 @@ def select(self, tablename, columns):
101101
@commit
102102
def delete(self, tablename, conditions, logic="AND"):
103103
conditions =f" {logic} ".join(conditions) if len(conditions) > 1 else conditions
104-
command = f"DELETE FROM {tablename} WHERE {conditions}"
104+
command = f"DELETE FROM {tablename} WHERE {conditions};"
105105
try:
106106
self.cursor.execute(command)
107107
except sql3.Error as er:
@@ -118,7 +118,7 @@ def update(self, tablename, columns, values):
118118
else:
119119
columns = ", ".join(columns)
120120
values = ", ".join(values)
121-
command = f"UPDATE {tablename} SET {columns} = {values}"
121+
command = f"UPDATE {tablename} SET {columns} = {values};"
122122
try:
123123
self.cursor.execute(command)
124124
except sql3.Error as er:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(
66
name="Lemon-Library",
7-
version="1.2.2",
7+
version="1.2.6",
88
packages=find_packages(),
99
install_requires=["parse==1.19.0", "waitress==2.1.2", "WebOb==1.8.7", "whitenoise==6.2.0"],
1010
author="Sasen Perera",

0 commit comments

Comments
 (0)