-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
54 lines (44 loc) · 1.28 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# -*- coding: utf-8 -*-
def snake_to_title_case(string):
return string.replace("_", " ").title().replace(" ", "")
def snake_to_camel_case(string):
snake = snake_to_title_case(string)
return snake[0].lower() + snake[1:]
def python_type_hint(string):
types = dict(
string = "str",
integer = "int",
bigint = "int",
smallint = "int",
datetime = "datetime",
date = "date",
decimal = "float",
numeric = "float",
)
return types[string]
def database_model_name(model):
return snake_to_title_case(model["table"])
def database_data_type(string):
types = dict(
string = "sqlalchemy.Text",
integer = "sqlalchemy.Integer",
bigint = "sqlalchemy.BigInteger",
smallint = "sqlalchemy.SmallInteger",
datetime = "sqlalchemy.DateTime",
date = "sqlalchemy.Date",
decimal = "sqlalchemy.Numeric(asdecimal=True)",
numeric = "sqlalchemy.Numeric()",
)
return types[string]
def graphql_data_type(string):
types = dict(
string = "String",
integer = "Int",
bigint = "Int",
smallint = "Int",
datetime = "DateTime",
date = "Date",
decimal = "Float",
numeric = "Float",
)
return types[string]