from curd import Session
mysql_conf = {
'type': 'mysql',
'conf': {
'host': '127.0.0.1',
'port': 3306,
'user': 'user',
'password': 'password',
}
}
session = Session([mysql_conf])
collection = 'test.test'
item = {'id': 1, 'text': 'test'}
session.create(collection, item)
Install with database driver as extras require (reduce install time)
pip install curd[mysql]
pip install curd[cassandra]
- Supported databases: cassandra / mysql (tidb
tidb_patch
). - Supported operations:
create
,filter
,update
,delete
,exist
. You can useexecute
for other operations (complex query). - Multiple threads/processes supported, you can share
Session
whatever you like. - Simple error handling.
ConnectError
,OperationFailure
,UnexpectedError
,ProgrammingError
,DuplicateKeyError
. - Operation timeout support for mysql.
-
Why not orm ?
Single point of truth.
-
Why
execute
?Sql is simpler for complex query.
-
Why fetchall, not paging?
Paging is too heavy due to complex web environments. You should handle it in your application.
-
Error handling
-
Retry when operation with
OperationFailure
errors like mysql
MySQL server has gone away
mysql connection timeout
mysql interface error
,cassandra
OperationFailure
. -
Raise when operation with
UnexpectedError
,ProgrammingError
(mostly sql error) -
Raise when creating connection with
ConnectError
-
Raise when create item with
DuplicateKeyError
-
-
Bulk operation
Not decided yet.