Usage Sample
''''''''''''
.. code:: python
from sqlormx import Model, db
from dataclasses import dataclass
@dataclass
class Person(Model):
__table__ = 'person'
id: int = None
name: str = None
age: int = None
if __name__ == '__main__':
db.init('test.db', driver='sqlite3', show_sql=True, debug=True)
db.init_db("postgres://user:password@127.0.0.1:5432/testdb", driver='psycopg2', pool_size=5)
db.init_db(host='127.0.0.1', port='3306', user='xxx', password='xxx', database='test', pool_size=5, show_sql=True)
effected_rowcount = Person.insert(name='tianqi', age=77)
persons = Person.query(name='tianqi')
# select id, name, age from person where name = :name
# result:
# {'id': 7, 'name': 'tianqi', 'age': 77}
persons = Person.query(name__eq='zhangsan')
# select id, name, age from person where name = :name
# result:
# [{'id': 3, 'name': 'zhangsan', 'age': 15}]
Transaction
'''''''''''
.. code:: python
from sqlormx import trans
@trans
def test_transaction():
insert_func(....)
update_func(....)
def test_transaction2():
with trans():
insert_func(....)
update_func(....)
If you want to operate MySQL database, may be you need MySqlx: https://pypi.org/project/mysqlx
If you want to operate PostgreSQL database, may be you need MySqlx: https://pypi.org/project/pgsqlx
If you just wanted a simple sql executor, may be you need sqlx-exec: https://pypi.org/project/sqlexecx
Raw data
{
"_id": null,
"home_page": "https://gitee.com/summry/sqlormx",
"name": "sqlormx",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "SQL, MySQL, PostgreSQL, SQLite, Database, Python, RDB",
"author": "summy",
"author_email": "xiazhongbiao@126.com",
"download_url": "https://files.pythonhosted.org/packages/dd/51/724fc829839ca1decf7c48d22828d1f487bb5e86bac7ca91c92ce2bd323b/sqlormx-0.5.0.tar.gz",
"platform": null,
"description": "Usage Sample\n''''''''''''\n\n.. code:: python\n\n from sqlormx import Model, db\n from dataclasses import dataclass\n\n @dataclass\n class Person(Model):\n __table__ = 'person'\n id: int = None\n name: str = None\n age: int = None\n\n if __name__ == '__main__':\n db.init('test.db', driver='sqlite3', show_sql=True, debug=True)\n db.init_db(\"postgres://user:password@127.0.0.1:5432/testdb\", driver='psycopg2', pool_size=5)\n db.init_db(host='127.0.0.1', port='3306', user='xxx', password='xxx', database='test', pool_size=5, show_sql=True)\n\n effected_rowcount = Person.insert(name='tianqi', age=77)\n\n persons = Person.query(name='tianqi')\n # select id, name, age from person where name = :name\n # result:\n # {'id': 7, 'name': 'tianqi', 'age': 77}\n\n persons = Person.query(name__eq='zhangsan')\n # select id, name, age from person where name = :name\n # result:\n # [{'id': 3, 'name': 'zhangsan', 'age': 15}]\n\nTransaction\n'''''''''''\n\n.. code:: python\n\n from sqlormx import trans\n\n @trans\n def test_transaction():\n insert_func(....)\n update_func(....)\n\n\n def test_transaction2():\n with trans():\n insert_func(....)\n update_func(....)\n\n\nIf you want to operate MySQL database, may be you need MySqlx: https://pypi.org/project/mysqlx\n\nIf you want to operate PostgreSQL database, may be you need MySqlx: https://pypi.org/project/pgsqlx\n\nIf you just wanted a simple sql executor, may be you need sqlx-exec: https://pypi.org/project/sqlexecx\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "A easy\uff0csingle table ORM framework for python. Support MySQL, PostgreSQL, SQLite etc.",
"version": "0.5.0",
"project_urls": {
"Homepage": "https://gitee.com/summry/sqlormx"
},
"split_keywords": [
"sql",
" mysql",
" postgresql",
" sqlite",
" database",
" python",
" rdb"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "dd51724fc829839ca1decf7c48d22828d1f487bb5e86bac7ca91c92ce2bd323b",
"md5": "64daff955a8708fa38d0230bcc684bce",
"sha256": "1bcc9d5015747c9127dd86415e63cfae9e7f8a16fceb90d9d2b0c2720058c0c1"
},
"downloads": -1,
"filename": "sqlormx-0.5.0.tar.gz",
"has_sig": false,
"md5_digest": "64daff955a8708fa38d0230bcc684bce",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 11085,
"upload_time": "2024-07-24T05:51:08",
"upload_time_iso_8601": "2024-07-24T05:51:08.290353Z",
"url": "https://files.pythonhosted.org/packages/dd/51/724fc829839ca1decf7c48d22828d1f487bb5e86bac7ca91c92ce2bd323b/sqlormx-0.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-24 05:51:08",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "sqlormx"
}