Skip to main content

使用 .env 的数据库连接

Project description

说明

使用 .env 的数据库连接

用法

pip install myally_database

项目根目录创建 .env 文件

DB_USER=名
DB_PASSWORD=数据库密码
DB_HOST=ip
DB_PORT=端口
DB_DATABASE=数据库

调用后用法与包 SQLAlchemy 一致

from myally_database import database
# 获取数据库会话
session = database.get_session()
# 提交事务
session.commit()
# 关闭会话
session.close()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

myally_database-1.0.tar.gz (1.6 kB view hashes)

Uploaded Source

Built Distribution

myally_database-1.0-py3-none-any.whl (2.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page