**df2mysql** 是一个用于连接和操作 Microsoft SQL Server 数据库的 Python 包。它提供了一个名为 **Database** 的类,可以使用该类的方法执行各种数据库操作,如创建和删除数据库、创建和删除表、插入和检索数据等。
使用方法:
以下是使用 **df2mysql** 包的一般步骤:
1. 安装包:通过运行 **pip install df2mysql** 安装包。
2. 导入包:在你的 Python 脚本或交互式会话中使用 **from df2mysql import Database** 导入 **Database**类。
3.创建 **Database** 实例:通过创建 **Database** 类的实例并提供 SQL Server 主机、用户名和密码来建立数据库连接。
```python
db = Database(host='your_host', user='your_username', password='your_password')
```
4.连接到数据库:使用 **connect_db(database)** 方法连接到指定的数据库。
```python
db.connect_db(database='your_database')
```
5.执行数据库操作:使用 **Database** 类提供的方法执行数据库操作,如创建表、插入数据、检索数据等。
```python
db.create_table(database='your_database', table_name='your_table', table_head=['column1', 'column2'])
db.insert_data(database='your_database', table_name='your_table', data=your_data)
result = db.select_data(database='your_database', table_name='your_table')
```
6.关闭连接:在完成所有数据库操作后,使用 close() 方法关闭数据库连接。
```python
db.close()
```
请确保已安装 pymssql 和其他所需的依赖项,并提供正确的数据库连接信息。这样,你就可以使用 df2mysql 包连接到 Microsoft SQL Server 数据库并执行相应的操作了。
Raw data
{
"_id": null,
"home_page": "https://github.com/ng-fukgin/df2mysql",
"name": "df2mysql",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "df2mysql,Microsoft SQL Server,\u6570\u636e\u5e93\u4ea4\u4e92,\u6570\u636e\u5e93\u8fde\u63a5,\u6570\u636e\u5e93\u64cd\u4f5c,\u6570\u636e\u5e93\u7ba1\u7406",
"author": "wfj",
"author_email": "wfj <wfj.0000@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/06/9a/ac53ffeaf5aef47bd81f7654d2bc11b84bc01de05007b93a43d07ddac24d/df2mysql-0.0.3.tar.gz",
"platform": "any",
"description": "**df2mysql** \u662f\u4e00\u4e2a\u7528\u4e8e\u8fde\u63a5\u548c\u64cd\u4f5c Microsoft SQL Server \u6570\u636e\u5e93\u7684 Python \u5305\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u540d\u4e3a **Database** \u7684\u7c7b\uff0c\u53ef\u4ee5\u4f7f\u7528\u8be5\u7c7b\u7684\u65b9\u6cd5\u6267\u884c\u5404\u79cd\u6570\u636e\u5e93\u64cd\u4f5c\uff0c\u5982\u521b\u5efa\u548c\u5220\u9664\u6570\u636e\u5e93\u3001\u521b\u5efa\u548c\u5220\u9664\u8868\u3001\u63d2\u5165\u548c\u68c0\u7d22\u6570\u636e\u7b49\u3002\r\n\r\n\u4f7f\u7528\u65b9\u6cd5\uff1a\r\n\u4ee5\u4e0b\u662f\u4f7f\u7528 **df2mysql** \u5305\u7684\u4e00\u822c\u6b65\u9aa4\uff1a\r\n\r\n1. \u5b89\u88c5\u5305\uff1a\u901a\u8fc7\u8fd0\u884c **pip install df2mysql** \u5b89\u88c5\u5305\u3002\r\n\r\n2. \u5bfc\u5165\u5305\uff1a\u5728\u4f60\u7684 Python \u811a\u672c\u6216\u4ea4\u4e92\u5f0f\u4f1a\u8bdd\u4e2d\u4f7f\u7528 **from df2mysql import Database** \u5bfc\u5165 **Database**\u7c7b\u3002\r\n\r\n3.\u521b\u5efa **Database** \u5b9e\u4f8b\uff1a\u901a\u8fc7\u521b\u5efa **Database** \u7c7b\u7684\u5b9e\u4f8b\u5e76\u63d0\u4f9b SQL Server \u4e3b\u673a\u3001\u7528\u6237\u540d\u548c\u5bc6\u7801\u6765\u5efa\u7acb\u6570\u636e\u5e93\u8fde\u63a5\u3002\r\n\r\n```python\r\ndb = Database(host='your_host', user='your_username', password='your_password')\r\n```\r\n4.\u8fde\u63a5\u5230\u6570\u636e\u5e93\uff1a\u4f7f\u7528 **connect_db(database)** \u65b9\u6cd5\u8fde\u63a5\u5230\u6307\u5b9a\u7684\u6570\u636e\u5e93\u3002\r\n\r\n\r\n```python\r\ndb.connect_db(database='your_database')\r\n```\r\n5.\u6267\u884c\u6570\u636e\u5e93\u64cd\u4f5c\uff1a\u4f7f\u7528 **Database** \u7c7b\u63d0\u4f9b\u7684\u65b9\u6cd5\u6267\u884c\u6570\u636e\u5e93\u64cd\u4f5c\uff0c\u5982\u521b\u5efa\u8868\u3001\u63d2\u5165\u6570\u636e\u3001\u68c0\u7d22\u6570\u636e\u7b49\u3002\r\n\r\n\r\n```python\r\ndb.create_table(database='your_database', table_name='your_table', table_head=['column1', 'column2'])\r\ndb.insert_data(database='your_database', table_name='your_table', data=your_data)\r\nresult = db.select_data(database='your_database', table_name='your_table')\r\n```\r\n6.\u5173\u95ed\u8fde\u63a5\uff1a\u5728\u5b8c\u6210\u6240\u6709\u6570\u636e\u5e93\u64cd\u4f5c\u540e\uff0c\u4f7f\u7528 close() \u65b9\u6cd5\u5173\u95ed\u6570\u636e\u5e93\u8fde\u63a5\u3002\r\n\r\n```python\r\ndb.close()\r\n```\r\n\r\n\u8bf7\u786e\u4fdd\u5df2\u5b89\u88c5 pymssql \u548c\u5176\u4ed6\u6240\u9700\u7684\u4f9d\u8d56\u9879\uff0c\u5e76\u63d0\u4f9b\u6b63\u786e\u7684\u6570\u636e\u5e93\u8fde\u63a5\u4fe1\u606f\u3002\u8fd9\u6837\uff0c\u4f60\u5c31\u53ef\u4ee5\u4f7f\u7528 df2mysql \u5305\u8fde\u63a5\u5230 Microsoft SQL Server \u6570\u636e\u5e93\u5e76\u6267\u884c\u76f8\u5e94\u7684\u64cd\u4f5c\u4e86\u3002\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "\u63d0\u4f9b\u4e86\u4e00\u7ec4\u65b9\u6cd5\uff0c\u7528\u4e8e\u4e0e Microsoft SQL Server \u6570\u636e\u5e93\u8fdb\u884c\u4ea4\u4e92\u3002\u5141\u8bb8\u6267\u884c\u5404\u79cd\u64cd\u4f5c\uff0c\u5982\u8fde\u63a5\u5230 SQL Server\u3001\u521b\u5efa\u548c\u5220\u9664\u6570\u636e\u5e93\u3001\u521b\u5efa\u548c\u5220\u9664\u8868\u3001\u6dfb\u52a0\u548c\u5220\u9664\u5217\u3001\u63d2\u5165\u548c\u68c0\u7d22\u6570\u636e\u7b49\u3002",
"version": "0.0.3",
"project_urls": {
"Homepage": "https://github.com/ng-fukgin/df2mysql",
"bugtracker": "https://github.com/ng-fukgin/df2mysql/issues",
"documentation": "https://github.com/ng-fukgin/df2mysql/wiki",
"repository": "https://github.com/ng-fukgin/df2mysql"
},
"split_keywords": [
"df2mysql",
"microsoft sql server",
"\u6570\u636e\u5e93\u4ea4\u4e92",
"\u6570\u636e\u5e93\u8fde\u63a5",
"\u6570\u636e\u5e93\u64cd\u4f5c",
"\u6570\u636e\u5e93\u7ba1\u7406"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3b2016a8a70417abfbf8e7e37260c02390a50d8a66a8bbd4ae47bb91ad2a201d",
"md5": "26b08d28c25ef89ec4c2af5af4fbd67a",
"sha256": "65fa9d5a09005c9b21847c9596838988441f3db007905c649673a464b12b1f92"
},
"downloads": -1,
"filename": "df2mysql-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "26b08d28c25ef89ec4c2af5af4fbd67a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 5318,
"upload_time": "2023-07-14T09:18:32",
"upload_time_iso_8601": "2023-07-14T09:18:32.922233Z",
"url": "https://files.pythonhosted.org/packages/3b/20/16a8a70417abfbf8e7e37260c02390a50d8a66a8bbd4ae47bb91ad2a201d/df2mysql-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "069aac53ffeaf5aef47bd81f7654d2bc11b84bc01de05007b93a43d07ddac24d",
"md5": "5e81125e560c3bd12670af4cf3a343ca",
"sha256": "d947eea9bb714604e81dabf99cc19f32c48ce63c7041e8615a5d0a4f16af3da1"
},
"downloads": -1,
"filename": "df2mysql-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "5e81125e560c3bd12670af4cf3a343ca",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 5589,
"upload_time": "2023-07-14T09:18:34",
"upload_time_iso_8601": "2023-07-14T09:18:34.230795Z",
"url": "https://files.pythonhosted.org/packages/06/9a/ac53ffeaf5aef47bd81f7654d2bc11b84bc01de05007b93a43d07ddac24d/df2mysql-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-14 09:18:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ng-fukgin",
"github_project": "df2mysql",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "df2mysql"
}