
Product
Introducing Data Exports
Export Socket alert data to your own cloud storage in JSON, CSV, or Parquet, with flexible snapshot or incremental delivery.
WkMysql
Advanced tools
The secondary encapsulation of pymysql provides a more user-friendly interface and thread pool, and will support SQLite in the future.
WkMysql 是一个用于简化与 MySQL 数据库交互的 Python 模块,专为单线程应用设计,适合短时间内快速连接 MySQL 数据库。通过此模块,您可以轻松执行数据库的创建、查询、插入、更新和删除等操作。
在使用 WkMysql 之前,请确保安装 pymysql 库:
pip install pymysql
pip install WkMysql
from WkMysql import WkMysql
db = WkMysql(
host='localhost',
user='root',
password='123456',
database='myproject'
)
设置当前操作的表:
db.set_table('test_table')
创建新表:
db.create_table({'id': 'INT PRIMARY KEY', 'name': 'VARCHAR(50)'})
插入一行数据:
result, insert_id = db.insert_row({'id': 1, 'name': 'wangkang'})
查询表中的所有数据:
all_data = db.select_all()
更新已有数据:
db.update({'id': 1}, {'name': 'new_name'})
删除特定行:
db.delete_row({'id': 1})
在程序结束时关闭数据库连接:
db.close()
以下是一个完整的示例,演示如何使用 WkMysql 包进行常见的数据库操作:
from WkMysql import WkMysql
db = WkMysql(
host='localhost',
user='root',
password='123456',
database='myproject'
)
db.set_table('test_table')
db.create_table({'id': 'INT PRIMARY KEY', 'name': 'VARCHAR(50)'})
db.insert_row({'id': 1, 'name': 'wangkang'})
results = db.select_all()
print(results)
db.update({'id': 1}, {'name': 'new_name'})
db.delete_row({'id': 1})
项目源代码及文档请访问:WkMysql 项目
本项目遵循 GPL2.0 许可证。请查看 LICENSE 文件以获取更多信息。
感谢您使用 WkMysql!如有任何问题或建议,请随时联系。
FAQs
The secondary encapsulation of pymysql provides a more user-friendly interface and thread pool, and will support SQLite in the future.
We found that WkMysql demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Export Socket alert data to your own cloud storage in JSON, CSV, or Parquet, with flexible snapshot or incremental delivery.

Research
/Security News
Bitwarden CLI 2026.4.0 was compromised in the Checkmarx supply chain campaign after attackers abused a GitHub Action in Bitwarden’s CI/CD pipeline.

Research
/Security News
Docker and Socket have uncovered malicious Checkmarx KICS images and suspicious code extension releases in a broader supply chain compromise.