Skip to content
This repository was archived by the owner on May 2, 2023. It is now read-only.
Merged
3 changes: 3 additions & 0 deletions sqeleton/abcs/database_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class TimestampTZ(TemporalType):
class Datetime(TemporalType):
pass

class Date(TemporalType):
pass


@dataclass
class NumericType(ColType):
Expand Down
4 changes: 3 additions & 1 deletion sqeleton/databases/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ def query(self, sql_ast: Union[Expr, Generator], res_type: type = None):
sys.exit(1)

res = self._query(sql_code)
if res_type is int:
if res_type is list:
return list(res)
elif res_type is int:
if not res:
raise ValueError("Query returned 0 rows, expected 1")
row = _one(res)
Expand Down
8 changes: 8 additions & 0 deletions sqeleton/databases/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
FractionalType,
ColType_UUID,
Boolean,
Date,
)
from ..abcs.mixins import (
AbstractMixin_MD5,
Expand Down Expand Up @@ -62,17 +63,24 @@ class Dialect(BaseDialect, Mixin_Schema):
# Dates
"datetime": Datetime,
"timestamp": Timestamp,
"date": Date,
# Numbers
"double": Float,
"float": Float,
"decimal": Decimal,
"int": Integer,
"bigint": Integer,
"smallint": Integer,
"tinyint": Integer,
# Text
"varchar": Text,
"char": Text,
"varbinary": Text,
"binary": Text,
"text": Text,
"mediumtext": Text,
"longtext": Text,
"tinytext": Text,
# Boolean
"boolean": Boolean,
}
Expand Down
2 changes: 2 additions & 0 deletions sqeleton/databases/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
Text,
FractionalType,
Boolean,
Date,
)
from ..abcs.mixins import AbstractMixin_MD5, AbstractMixin_NormalizeValue
from .base import BaseDialect, ThreadedDatabase, import_helper, ConnectError, Mixin_Schema
Expand Down Expand Up @@ -60,6 +61,7 @@ class PostgresqlDialect(BaseDialect, Mixin_Schema):
"timestamp with time zone": TimestampTZ,
"timestamp without time zone": Timestamp,
"timestamp": Timestamp,
"date": Date,
# Numbers
"double precision": Float,
"real": Float,
Expand Down