orm-database 0.3.23__py3-none-any.whl → 0.3.25__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- orm_database/orm_database.py +10 -0
- orm_database/orm_query.py +20 -0
- {orm_database-0.3.23.dist-info → orm_database-0.3.25.dist-info}/METADATA +56 -1
- orm_database-0.3.25.dist-info/RECORD +8 -0
- orm_database-0.3.23.dist-info/RECORD +0 -8
- {orm_database-0.3.23.dist-info → orm_database-0.3.25.dist-info}/LICENSE +0 -0
- {orm_database-0.3.23.dist-info → orm_database-0.3.25.dist-info}/WHEEL +0 -0
- {orm_database-0.3.23.dist-info → orm_database-0.3.25.dist-info}/top_level.txt +0 -0
orm_database/orm_database.py
CHANGED
@@ -117,6 +117,16 @@ class PostgreSQL:
|
|
117
117
|
query = query_insert_values(table=table,value=value)
|
118
118
|
await self.db.execute(query)
|
119
119
|
|
120
|
+
|
121
|
+
async def insert_values_truple(self, table: str, key:dict,value:list):
|
122
|
+
query = query_insert_values_truple(table=table,key=key)
|
123
|
+
await self.db.executemany(query,value)
|
124
|
+
|
125
|
+
async def copy_records_to_table(self, table: str, value:list):
|
126
|
+
await self.db.copy_records_to_table(table,records=value)
|
127
|
+
|
128
|
+
|
129
|
+
|
120
130
|
async def select_all(self, table: str, filed: list, all: bool = False):
|
121
131
|
if all == True:
|
122
132
|
query = "SELECT * FROM " + table
|
orm_database/orm_query.py
CHANGED
@@ -80,6 +80,26 @@ def query_insert_values(table:str,value:dict):
|
|
80
80
|
return query
|
81
81
|
|
82
82
|
|
83
|
+
|
84
|
+
def query_insert_values_truple(table:str,key:dict):
|
85
|
+
query = f"INSERT INTO {table} ( "
|
86
|
+
filed_key = list(key.keys())
|
87
|
+
for a in filed_key:
|
88
|
+
query = query + " " + a + " " + ","
|
89
|
+
query = query[:-1]
|
90
|
+
query = query + ")"
|
91
|
+
query = query + " VALUES ("
|
92
|
+
|
93
|
+
filed_value = list(key.values())
|
94
|
+
namber = 1
|
95
|
+
for a in filed_value:
|
96
|
+
|
97
|
+
query = query + " " + "$" + str(namber) + " " + ","
|
98
|
+
namber = namber + 1
|
99
|
+
query = query[:-1]
|
100
|
+
query = query + ")"
|
101
|
+
return query
|
102
|
+
|
83
103
|
# print output SELECT * FROM tes
|
84
104
|
# print output SELECT user_rt FROM tes
|
85
105
|
def query_select(table:str,filed:list,all:bool=False):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: orm_database
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.25
|
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
|
@@ -290,3 +290,58 @@ data = await postgres.find_list("test",{'username':'s1'})
|
|
290
290
|
]
|
291
291
|
|
292
292
|
```
|
293
|
+
|
294
|
+
## insert value list truple
|
295
|
+
|
296
|
+
|
297
|
+
```python
|
298
|
+
from orm_database import PostgreSQL
|
299
|
+
import asyncio
|
300
|
+
from pydantic import BaseModel , Field
|
301
|
+
|
302
|
+
|
303
|
+
db = PostgreSQL(host="127.0.0.1",database="test",password="12341234",user="postgres")
|
304
|
+
|
305
|
+
class users(BaseModel):
|
306
|
+
user_rt : str = Field(varchar=20)
|
307
|
+
password_rt : str = Field(varchar=20)
|
308
|
+
email_rt : str = Field(varchar=20)
|
309
|
+
|
310
|
+
|
311
|
+
async def main():
|
312
|
+
data = [("test1","12342","test4@mail.com"),("test2","12342","test2@mail.com"),("test3","12343","test3@mail.com")]
|
313
|
+
key = {"user_rt":"","password_rt":"","email_rt":""}
|
314
|
+
await db.start()
|
315
|
+
await db.teble_create_BaseModel("tes",users)
|
316
|
+
await db.insert_values_truple("tes",key=key,value=data)
|
317
|
+
|
318
|
+
|
319
|
+
asyncio.run(main())
|
320
|
+
```
|
321
|
+
|
322
|
+
|
323
|
+
## copy records to table
|
324
|
+
```python
|
325
|
+
from orm_database import PostgreSQL
|
326
|
+
import asyncio
|
327
|
+
from pydantic import BaseModel , Field
|
328
|
+
|
329
|
+
|
330
|
+
db = PostgreSQL(host="127.0.0.1",database="test",password="12341234",user="postgres")
|
331
|
+
|
332
|
+
class users(BaseModel):
|
333
|
+
user_rt : str = Field(varchar=20)
|
334
|
+
password_rt : str = Field(varchar=20)
|
335
|
+
email_rt : str = Field(varchar=20)
|
336
|
+
|
337
|
+
|
338
|
+
async def main():
|
339
|
+
data = [("test1","12342","test4@mail.com"),("test2","12342","test2@mail.com"),("test3","12343","test3@mail.com")]
|
340
|
+
key = {"user_rt":"","password_rt":"","email_rt":""}
|
341
|
+
await db.start()
|
342
|
+
await db.teble_create_BaseModel("tes",users)
|
343
|
+
await db.copy_records_to_table(table="tes",value=data)
|
344
|
+
|
345
|
+
|
346
|
+
asyncio.run(main())
|
347
|
+
```
|
@@ -0,0 +1,8 @@
|
|
1
|
+
orm_database/__init__.py,sha256=q0A0dUBMacf_yaU5m4VWCDlP__pVAz3I1Bhn1RPkv9I,140
|
2
|
+
orm_database/orm_database.py,sha256=Ez1JjvMD13ZIvenxgk1DRKmFaTgj1VuIbXaLWGlTgPU,8260
|
3
|
+
orm_database/orm_query.py,sha256=cykc-uNzLYV9_m1m6oc6EIS9UQrS3xpmDfjco3o-GD8,4420
|
4
|
+
orm_database-0.3.25.dist-info/LICENSE,sha256=v33KAoqx5qhyUNlHOjYmBBKDtd9ymzWB7sR4cova190,1064
|
5
|
+
orm_database-0.3.25.dist-info/METADATA,sha256=31U2psohS4qzVG4-qZ6xfXd5XIUoMI4r3eJ6nWWaa1Q,7179
|
6
|
+
orm_database-0.3.25.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
7
|
+
orm_database-0.3.25.dist-info/top_level.txt,sha256=dzcxzqcdsX4x3lqSkz1tVcu1qKX02rXOu6QN3cHggU4,13
|
8
|
+
orm_database-0.3.25.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
orm_database/__init__.py,sha256=q0A0dUBMacf_yaU5m4VWCDlP__pVAz3I1Bhn1RPkv9I,140
|
2
|
-
orm_database/orm_database.py,sha256=O66Adl0Ui6ZaAkAlGYdV-5K5_DQIFTjfaqzfGjrLgag,7917
|
3
|
-
orm_database/orm_query.py,sha256=7fZo-S34z-ZYEE3cdsXvVcoZLQXgrbQi8j1qaCDGMdQ,3907
|
4
|
-
orm_database-0.3.23.dist-info/LICENSE,sha256=v33KAoqx5qhyUNlHOjYmBBKDtd9ymzWB7sR4cova190,1064
|
5
|
-
orm_database-0.3.23.dist-info/METADATA,sha256=6v50UclwYMEwNFQlyvBrEIl3gPF-kbYQnnuH1V1566o,5756
|
6
|
-
orm_database-0.3.23.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
7
|
-
orm_database-0.3.23.dist-info/top_level.txt,sha256=dzcxzqcdsX4x3lqSkz1tVcu1qKX02rXOu6QN3cHggU4,13
|
8
|
-
orm_database-0.3.23.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|