PostgreSql 代码配置某schema(模式)并操作其表
编程语言:python一、sql语言操作注:以下以 sm表示模式名称,table表示表名1、查找select * from sm.table2、添加insert into sm.table(username, password) values(“xxxx”, “yyyy”)3、更新update sm.table set password=“zzzz” where username=“xxxx”3、
·
编程语言:python
版 本:3.6.7
一、sql语言操作
注:以下以 sm表示模式名称,table表示表名
1、查找
select * from sm.table
2、添加
insert into sm.table(username, password) values(“xxxx”, “yyyy”)
3、更新
update sm.table set password=“zzzz” where username=“xxxx”
3、删除
delete from sm.table where username=“xxxx”
二、SQLAlchemy操作
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class User(db.Model):
__tablename__ = 'user'
__table_args__ = ({"schema": "test"})
username = db.Column(db.String(255), nullable=False)
password = db.Column(db.String(255), nullable=False)
user_code = db.Column(db.String(255), primary_key=True)
def __repr__(self):
return '<User表 %r>' % self.username
更多推荐
所有评论(0)