connect to database
Project description
database操作(支持 mysql mongodb elasticSearch sqlite3)
How to use
mysql
connect
mysql = MySql("localhost", "root", "123456", "test")
insert
# insert into test values(1,'Mike','male')
mysql.insert_one("test", columns_list=[1, "Mike", "male"])
# insert into test(id,name,gender) values(1,'Mike','male')
mysql.insert_one("test", columns_dict={"id": 1, "name": "Mike", "gender": "male"})
update
# update test set id=12 where id>12
mysql.update('test', {'id': 12}, {"id": {
"compare": ">",
"value": 12
}})
# update test set id=12 where name='mike'
mysql.update('test', {'id': 12}, {"name": "mike"})
select
# select * from test;
mysql.select("test")
# select name,score,age from test;
mysql.select("test",["name","score","age"])
# select name,score,age from test where name='XiaoMing';
mysql.select("test",["name","score","age"],{'name':'XiaoMing'})
delete
# delete from test;
mysql.delete("test")
# delete from test where name='LiBai'
mysql.delete("test",{"name":"LiBai"})
mongodb
elasticSearch
sqlite3
connect
sqlite = Sqlite("localhost", "root", "123456", "test")
insert
# insert into test values(1,'Mike','male')
sqlite.insert_one("test", columns_list=[1, "Mike", "male"])
# insert into test(id,name,gender) values(1,'Mike','male')
sqlite.insert_one("test", columns_dict={"id": 1, "name": "Mike", "gender": "male"})
update
# update test set id=12 where id>12
sqlite.update('test', {'id': 12}, {"id": {
"compare": ">",
"value": 12
}})
# update test set id=12 where name='mike'
sqlite.update('test', {'id': 12}, {"name": "mike"})
select
# select * from test;
sqlite.select("test")
# select name,score,age from test;
sqlite.select("test",["name","score","age"])
# select name,score,age from test where name='XiaoMing';
sqlite.select("test",["name","score","age"],{'name':'XiaoMing'})
delete
# delete from test;
sqlite.delete("test")
# delete from test where name='LiBai'
sqlite.delete("test",{"name":"LiBai"})
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py3db-0.0.19.tar.gz
(8.0 kB
view details)
Built Distribution
py3db-0.0.19-py3-none-any.whl
(11.3 kB
view details)
File details
Details for the file py3db-0.0.19.tar.gz
.
File metadata
- Download URL: py3db-0.0.19.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10b58c0d4b5e9790bdbce296eb31f788d7b6fe149072f21f52e17528b8f47447 |
|
MD5 | b8ade0c99191ba472ecddeb42daed71c |
|
BLAKE2b-256 | ba3727912563bc30e602d521426adf1cfa97ba97570879bf74caaed2355cf45c |
File details
Details for the file py3db-0.0.19-py3-none-any.whl
.
File metadata
- Download URL: py3db-0.0.19-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a705d1f89c03f28a94e8ac9ef9229f845c289e9a5b50bb455d1cf35012446d44 |
|
MD5 | 879e54ef19d30c95523eeeed2b3c7be2 |
|
BLAKE2b-256 | faa81f5133ee5c78ff58a7357de5f1bdc6133f1a33ec3227174e76f4901db5af |