Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.vscode/*
*/__pycache__/*
__pycache__
*.pyc
__local/*
*.db
Expand All @@ -11,3 +12,4 @@ MercurySQL.egg-info/*
runtime
runtime/*
*.test.py

7 changes: 7 additions & 0 deletions MercurySQL/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@

from .gensql import DataBase, Table, set_driver
from . import drivers

class SQL:
"""Wrap everything together"""
DataBase = DataBase
Table = Table
set_driver = set_driver
drivers = drivers
Original file line number Diff line number Diff line change
Expand Up @@ -190,22 +190,22 @@ def parse(type_: Any) -> str:
return res

@staticmethod
def connect(db_name: str, host: str, user: str, passwd: str = '', force=False) -> Conn:
def connect(db_name: str, host: str, user: str, password: str = '', force=False) -> Conn:
"""
Connect to a MySQL database.
"""
if force:
return mysql.connector.connect(
host=host,
user=user,
passwd=passwd,
passwd=password,
database=db_name
)
else:
conn = mysql.connector.connect(
host=host,
user=user,
passwd=passwd
passwd=password
)
conn.backup_cursor = conn.cursor

Expand Down
3 changes: 3 additions & 0 deletions MercurySQL/gensql/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
from .table import Table


from ..drivers import sqlite


# ========== Class Decorations ==========
class DataBase:
pass
Expand Down
11 changes: 9 additions & 2 deletions MercurySQL/gensql/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,15 @@ def insert(self, __auto=False, **kwargs) -> None:
table.insert(id=1, name='Bernie', age=15, __auto=True)

"""
# get keys and clean them
keys = list(kwargs.keys())

# if __auto is a dict
if isinstance(__auto, dict):
keys = list(__auto.keys())
kwargs = __auto
else:
# get keys and clean them
keys = list(kwargs.keys())

if "__auto" in keys:
__auto = kwargs["__auto"]
keys.remove("__auto")
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ sphinx_rtd_theme

# for release
wheel

# MySQL
mysql.connector