orm-database 0.3.15__tar.gz → 0.3.17__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: orm_database
3
- Version: 0.3.15
3
+ Version: 0.3.17
4
4
  Summary: This module is written to launch your programs with any database you want in the shortest time
5
5
  Home-page: https://github.com/sisrsis/orm-database
6
6
  Author: SISRSIS
@@ -59,6 +59,7 @@ from pydantic import BaseModel , Field
59
59
  db = MariaDB(host="127.0.0.1",database="login",password="",port=3306,user="root")
60
60
 
61
61
  class users(BaseModel):
62
+ id : int = Field("SERIAL PRIMARY KEY")
62
63
  user_rt : str = Field(varchar=20)
63
64
  password_rt : str = Field(varchar=20)
64
65
  email_rt : str = Field(varchar=20)
@@ -249,3 +250,6 @@ output
249
250
  ```
250
251
  ('test1', '12341', 'test1@mail.com')
251
252
  ```
253
+
254
+
255
+
@@ -37,6 +37,7 @@ from pydantic import BaseModel , Field
37
37
  db = MariaDB(host="127.0.0.1",database="login",password="",port=3306,user="root")
38
38
 
39
39
  class users(BaseModel):
40
+ id : int = Field("SERIAL PRIMARY KEY")
40
41
  user_rt : str = Field(varchar=20)
41
42
  password_rt : str = Field(varchar=20)
42
43
  email_rt : str = Field(varchar=20)
@@ -226,4 +227,7 @@ output
226
227
 
227
228
  ```
228
229
  ('test1', '12341', 'test1@mail.com')
229
- ```
230
+ ```
231
+
232
+
233
+
@@ -1,8 +1,10 @@
1
1
  def query_baseModel_create_table(table,class_BaseModel):
2
2
  query = f"CREATE TABLE {table} ("
3
3
  result=class_BaseModel.model_json_schema()
4
+ list_keys = result['properties']
5
+ list_keys = list(list_keys.keys())
4
6
  type=""
5
- for a in result['required']:
7
+ for a in list_keys:
6
8
  data = result['properties'][a]
7
9
  if len(data.keys()) == 2:
8
10
  match data["type"]:
@@ -16,17 +18,21 @@ def query_baseModel_create_table(table,class_BaseModel):
16
18
  type = "bool"
17
19
  query = query + a + " " + type + ","
18
20
  else :
19
- match data["type"]:
20
- case "string":
21
- type = f"varchar({data["varchar"]})"
22
- case "number":
23
- type = "float"
24
- case "integer":
25
- type = "int"
26
- case "boolean":
27
- type = "bool"
28
-
29
- query = query + a + " " + type + ","
21
+ try:
22
+ type = data["default"]
23
+ query = query + a + " " + type + ","
24
+ except:
25
+ match data["type"]:
26
+ case "string":
27
+ type = f"varchar({data["varchar"]})"
28
+ case "number":
29
+ type = "float"
30
+ case "integer":
31
+ type = "int"
32
+ case "boolean":
33
+ type = "bool"
34
+
35
+ query = query + a + " " + type + ","
30
36
  query = query[:-1]
31
37
  query = query + ")"
32
38
  return query
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: orm_database
3
- Version: 0.3.15
3
+ Version: 0.3.17
4
4
  Summary: This module is written to launch your programs with any database you want in the shortest time
5
5
  Home-page: https://github.com/sisrsis/orm-database
6
6
  Author: SISRSIS
@@ -59,6 +59,7 @@ from pydantic import BaseModel , Field
59
59
  db = MariaDB(host="127.0.0.1",database="login",password="",port=3306,user="root")
60
60
 
61
61
  class users(BaseModel):
62
+ id : int = Field("SERIAL PRIMARY KEY")
62
63
  user_rt : str = Field(varchar=20)
63
64
  password_rt : str = Field(varchar=20)
64
65
  email_rt : str = Field(varchar=20)
@@ -249,3 +250,6 @@ output
249
250
  ```
250
251
  ('test1', '12341', 'test1@mail.com')
251
252
  ```
253
+
254
+
255
+
@@ -6,7 +6,7 @@ long_description = (this_directory / "README.md").read_text()
6
6
 
7
7
  setup(
8
8
  name='orm_database',
9
- version='0.3.15',
9
+ version='0.3.17',
10
10
  description='This module is written to launch your programs with any database you want in the shortest time ',
11
11
  license="MIT",
12
12
  author='SISRSIS',
File without changes
File without changes