Skip to content

Commit

Permalink
insert last row id
Browse files Browse the repository at this point in the history
  • Loading branch information
zxyle committed Aug 7, 2019
1 parent 70be0fb commit 418dc66
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tinycrud/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def insert(self, tb, doc):
fields_sql = ", ".join(fields)
values_sql = ", ".join(["%s" for _ in range(len(values))])
sql = f"INSERT INTO `{tb}` ({fields_sql}) VALUES ({values_sql});"
self.execute(sql, values)
return self.execute(sql, values)

def insert_many(self, tb, doc_list):
"""
Expand Down Expand Up @@ -79,6 +79,8 @@ def execute(self, sql, data=None):
return rows[0]
elif len(rows) > 1:
return rows
elif len(rows) == 0:
return cursor.lastrowid

def create_db(self, db_name=""):
"""Create Database operation"""
Expand Down

0 comments on commit 418dc66

Please sign in to comment.