pip install curd2
from curd2 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)- Supported databases: cassandra / mysql (tidb
tidb_patch)/PolarDB. - Supported operations:
create,filter,update,delete,exist. You can useexecutefor other operations (complex query). - Multiple threads/processes supported, you can share
Sessionwhatever 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
OperationFailureerrors like mysql
MySQL server has gone awaymysql connection timeoutmysql 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.