{"id":20770310,"url":"https://github.com/fling-asia/tonydbc","last_synced_at":"2025-04-30T13:43:31.689Z","repository":{"id":216058863,"uuid":"740008792","full_name":"Fling-Asia/tonydbc","owner":"Fling-Asia","description":"High-level DB connector for MariaDB","archived":false,"fork":false,"pushed_at":"2024-11-11T05:48:47.000Z","size":179,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-15T21:43:34.887Z","etag":null,"topics":["database","mariadb","mariadb-connector","pandas"],"latest_commit_sha":null,"homepage":"https://github/Fling-Asia/tonydbc","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Fling-Asia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-07T08:28:00.000Z","updated_at":"2024-11-06T19:08:47.000Z","dependencies_parsed_at":"2024-01-19T10:05:05.676Z","dependency_job_id":"2bfc2f64-c378-4ee7-ba6f-784e9752b58f","html_url":"https://github.com/Fling-Asia/tonydbc","commit_stats":null,"previous_names":["fling-asia/tonydbc"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fling-Asia%2Ftonydbc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fling-Asia%2Ftonydbc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fling-Asia%2Ftonydbc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fling-Asia%2Ftonydbc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fling-Asia","download_url":"https://codeload.github.com/Fling-Asia/tonydbc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225034582,"owners_count":17410528,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","mariadb","mariadb-connector","pandas"],"created_at":"2024-11-17T12:08:36.326Z","updated_at":"2025-04-30T13:43:31.682Z","avatar_url":"https://github.com/Fling-Asia.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TonyDBC\n\nLatest version: 1.2.25\n\nAvailable on PyPI: https://pypi.org/project/tonydbc/\n\n2024-01-07: [Release announcement on Medium](https://mcurrie-59915.medium.com/introducing-tonydbc-a-high-level-database-connector-for-mariadb-python-and-pandas-8600676fbf88)\n\nSupports high-level database operations within Python.  TonyDBC is short for Tony’s Database Connector, named for Maria’s lover in West Side Story.\n\nTonyDBC uses the MariaDB/Connector but adds these features:\n\n* Support for the object-oriented context manager design pattern, which automatically closes connections.\n* A way to convert between pandas DataFrames and MariaDB tables, including serialization of complex data types like dictionaries and numpy arrays.\n* A way to autoresume when the connection is lost.\n* Support for fast INSERT and UPDATE from DataFrame.to_sql. Currently pandas’ implemention using sqlalchemy is 300x slower.\n* A way to quickly and automatically clone a database from a DDL script and copy the contents from the production database.\n* Batch INSERT and UPDATE offline and resume when Internet is available.\n* Logging database actions using the standard logging module.\n* In a CI/CD context, automatically connecting to the correct production or test database.\n* Support for the np.Int64Dtype data type.\n* Support for pandas timestamps.\n* Able to bulk insert data containing NULLs\n\n### Installation\n\nTo install TonyDBC from PyPI on Windows:\n\n```bash\npip install tonydbc\n```\n\nTo install TonyDBC on Ubuntu or Debian, first the MariaDB Connector / C must be installed, then the MariaDB Connector / Python must be installed, because neither can be installed via `pip3`:\n\n```bash\ncd ~\n\nsudo apt-get install -y wget curl python3-packaging gcc\n\n# Install mariadb CS Package Repository so apt-get can find the right package\n# See https://mariadb.com/docs/skysql/connect/programming-languages/c/install/#Installation_via_Package_Repository_(Linux)\nwget https://r.mariadb.com/downloads/mariadb_repo_setup || wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup\nchmod +x mariadb_repo_setup\nsudo ./mariadb_repo_setup  --mariadb-server-version=\"mariadb-11.1.5\"\nsudo apt-get install -y libmariadb3 libmariadb-dev\n\npip3 install tonydbc\n```\n\n### Usage\n\nA typical use case:\n\n```python\nfrom tonydbc import TonyDBC, load_dotenvs\nimport pandas as pd\n\nload_dotenvs()\n\nsql_params = {\n    \"host\": os.environ[\"MYSQL_HOST\"],\n    \"user\": os.environ[\"MYSQL_USER\"],\n    \"password\": os.environ[\"MYSQL_PASSWORD\"],\n    \"database\": os.environ[\"MYSQL_DATABASE\"],\n    \"port\": int(os.environ[\"MYSQL_PORT\"]),\n}\n\nwith TonyDBC(**sql_params) as db:\n    # Do stuff\n    contoso_users_df = db.query_table(\"user\", f\"\"\"\n        SELECT *\n        FROM `user`\n        WHERE\n            `user`.`company` = 'Contoso'\n        LIMIT 10;\n        \"\"\")\n\n    print(contoso_users_df.first_name)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffling-asia%2Ftonydbc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffling-asia%2Ftonydbc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffling-asia%2Ftonydbc/lists"}