diff --git a/tinycrud/mysql.py b/tinycrud/mysql.py index 96b0822..c347edb 100644 --- a/tinycrud/mysql.py +++ b/tinycrud/mysql.py @@ -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): """ @@ -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"""