Ai
4 Star 9 Fork 0

Gitee 极速下载/py-postgresql

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/Kevin-Chen0/py-postgresql
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
example.py 1015 Bytes
一键复制 编辑 原始数据 按行查看 历史
kevrchen 提交于 2019-01-27 13:25 +08:00 . genesis
# coding=utf-8
from py_post.sql import Session
from py_post.table import CreateTable, InsertTable
new_table = CreateTable(name='vendor')
new_table.add_field('part_id', 'INT', can_null=False, is_unique=True)
new_table.add_field('part_name', 'VARCHAR(255)')
# Remeber the set your own username and password here.
session = Session(db='test', usr='postgres', pwd='pass')
session.to_sql(str(new_table))
'''
str(table):
CREATE TABLE vendor (part_id INT NOT NULL UNIQUE, part_name VARCHAR(255));
'''
field_names = list(new_table.fields['name'].values)
insert_table = InsertTable(name='vendor', fields=field_names)
insert_table.add_row('11111', 'pencil')
insert_table.add_row('22222', 'pen')
insert_table.add_row('33333', 'paper')
insert_table.add_row('44444', 'parcel')
insert_table.add_row('55555', 'package')
session.to_sql(str(insert_table))
'''
str(table):
INSERT INTO vendor VALUES (11111, 'pencil'), (22222, 'pen'),
(33333, 'paper'), (44444, 'parcel'), (55555, 'package')
'''
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mirrors/py-postgresql.git
git@gitee.com:mirrors/py-postgresql.git
mirrors
py-postgresql
py-postgresql
master

搜索帮助