Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f66ec47

Browse files
committedFeb 24, 2023
refs #90 Cleanup, use lambdas
lambdas make much more sense here
1 parent 9389fd5 commit f66ec47

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed
 

‎pysimplesql/pysimplesql.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2701,10 +2701,10 @@ def __init__(self, driver:SQLDriver, table_name:str):
27012701
'FLOAT': 0.0,
27022702
'DECIMAL': 0.0,
27032703
'BOOLEAN': 0,
2704-
'TIME': self.default_time(),
2705-
'DATE': self.default_date(),
2706-
'TIMESTAMP': self.default_datetime(),
2707-
'DATETIME': self.default_datetime()
2704+
'TIME': lambda x: datetime.now().strftime("%H:%M:%S"),
2705+
'DATE': lambda x: date.today().strftime("%Y-%m-%d"),
2706+
'TIMESTAMP': lambda x: datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
2707+
'DATETIME': lambda x: datetime.now().strftime("%Y-%m-%d %H:%M:%S")
27082708
}
27092709
super().__init__()
27102710

@@ -2800,15 +2800,6 @@ def _contains_key_value_pair(self, key, value): #used by __contains__
28002800
return True
28012801
return False
28022802

2803-
def default_time(self):
2804-
return datetime.now().strftime("%H:%M:%S")
2805-
2806-
def default_date(self):
2807-
return date.today().strftime("%Y-%m-%d")
2808-
2809-
def default_datetime(self):
2810-
return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
2811-
28122803
def set_null_default(self, sql_type:str, value:object) -> None:
28132804
"""
28142805
Set a Null default for a single SQL type

0 commit comments

Comments
 (0)
Please sign in to comment.