Aestate
Classes | Public Member Functions | Public Attributes | Private Attributes | List of all members
aestate.work.orm.AOrm Class Reference
Inheritance diagram for aestate.work.orm.AOrm:
Inheritance graph
Collaboration diagram for aestate.work.orm.AOrm:
Collaboration graph

Classes

class  Mode
 

Public Member Functions

def __init__ (self, repository)
 
def top (self)
 
def first (self)
 
def find (self, *args, **kwargs)
 
def order_by (self, *args, **kwargs)
 
def group_by (self, *args, **kwargs)
 
def by_opera (self, field, args_list, **kwargs)
 
def filter (self, **kwargs)
 
def where (self, **kwargs)
 
def on (self, from_where, to_where, symbol='=')
 
def limit (self, start=0, end=None)
 
def desc (self)
 
def set (self, **kwargs)
 
def ander (self)
 
QuerySet run (self, need_sql=False, serializer=True)
 
def con_from (self)
 
def append (self, app_sql)
 
def rep_sym (self, sym=',', rep='')
 
def end (self, **kwargs)
 
def __rshift__ (self, other)
 
def __lshift__ (self, other)
 
def alias (self, name)
 
def left_join (self, sql_orm, name)
 
def __str__ (self)
 
def check (self)
 
def create (self)
 

Public Attributes

 exmode
 
 args
 
 params
 
 sqlFields
 
 ParseUtil
 
 serializer
 
 repository
 
 first_data
 

Private Attributes

 __table_name__
 
 _result
 

Detailed Description

纯净的ORM模式:
    你可以使用find('table').by('args').order_by('args').desc().end()方式执行sql
    好处就是:
        能更好的拒绝sql注入
        无需写sql语句
        代码简单易懂
        上手快

Definition at line 67 of file orm.py.

Constructor & Destructor Documentation

◆ __init__()

def aestate.work.orm.AOrm.__init__ (   self,
  repository 
)
初始化ORM


自定义方言除了可使用默认已存在的方法,还可以使用自定义sql方言拼接

:param repository:仓库
s        

Definition at line 82 of file orm.py.

Member Function Documentation

◆ __lshift__()

def aestate.work.orm.AOrm.__lshift__ (   self,
  other 
)
将右边迁移至左边

Definition at line 468 of file orm.py.

Here is the call graph for this function:

◆ __rshift__()

def aestate.work.orm.AOrm.__rshift__ (   self,
  other 
)
将左边orm迁移至右边

Definition at line 458 of file orm.py.

◆ __str__()

def aestate.work.orm.AOrm.__str__ (   self)

Definition at line 494 of file orm.py.

◆ alias()

def aestate.work.orm.AOrm.alias (   self,
  name 
)
设置别名

Definition at line 478 of file orm.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ander()

def aestate.work.orm.AOrm.ander (   self)
和
example:
    update('table').set('param1','value1').and().set('param2','value2')
    update('table').set('param1','value1').and().set('param2','value2').end()
    update('table').set('param1','value1').and().set('param2','value2').where('param3=value3').end()

Definition at line 365 of file orm.py.

Here is the call graph for this function:

◆ append()

def aestate.work.orm.AOrm.append (   self,
  app_sql 
)
末尾追加一些sql

Definition at line 440 of file orm.py.

Here is the caller graph for this function:

◆ by_opera()

def aestate.work.orm.AOrm.by_opera (   self,
  field,
  args_list,
**  kwargs 
)
根据什么查

Definition at line 212 of file orm.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check()

def aestate.work.orm.AOrm.check (   self)
sudo apt install containerd
检查表结构与数据库中是否对应

Definition at line 498 of file orm.py.

◆ con_from()

def aestate.work.orm.AOrm.con_from (   self)
如果没有被from包含,则在末尾加上from __table_name__关键字

Definition at line 429 of file orm.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create()

def aestate.work.orm.AOrm.create (   self)

Definition at line 504 of file orm.py.

Here is the caller graph for this function:

◆ desc()

def aestate.work.orm.AOrm.desc (   self)
倒叙
example:
    find('all').desc()
    find('all').desc().end()
    find('all').order_by('param').desc().limit(10,20)

Definition at line 326 of file orm.py.

Here is the call graph for this function:

◆ end()

def aestate.work.orm.AOrm.end (   self,
**  kwargs 
)

Definition at line 455 of file orm.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filter()

def aestate.work.orm.AOrm.filter (   self,
**  kwargs 
)

Definition at line 227 of file orm.py.

Here is the call graph for this function:

◆ find()

def aestate.work.orm.AOrm.find (   self,
args,
**  kwargs 
)
查
example:
    find('all')
    find('param1',asses=['p'],h_func=True)
Attributes:
    asses:将对应的字段转成另一个别名,不需要转换的使用None标识
    h_func:不将字段转换成 `%s` 格式
更新:
    如果args字段长度为0,默认为查找全部

Definition at line 125 of file orm.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ first()

def aestate.work.orm.AOrm.first (   self)
是否只返回第一行数据

Definition at line 117 of file orm.py.

Here is the caller graph for this function:

◆ group_by()

def aestate.work.orm.AOrm.group_by (   self,
args,
**  kwargs 
)
聚合函数
example:
    select shop_id,count(*) as count from comments group by shop_id having count>1;

Definition at line 204 of file orm.py.

Here is the call graph for this function:

◆ left_join()

def aestate.work.orm.AOrm.left_join (   self,
  sql_orm,
  name 
)
left join

Definition at line 486 of file orm.py.

Here is the call graph for this function:

◆ limit()

def aestate.work.orm.AOrm.limit (   self,
  start = 0,
  end = None 
)
分页
:param start:开始
:param end:末尾
example:
    find('all').limit(start=10,end=20)
    find('all').limit(end=10)

Definition at line 306 of file orm.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on()

def aestate.work.orm.AOrm.on (   self,
  from_where,
  to_where,
  symbol = '=' 
)

Definition at line 295 of file orm.py.

Here is the call graph for this function:

◆ order_by()

def aestate.work.orm.AOrm.order_by (   self,
args,
**  kwargs 
)
根据什么查
example:
    find('all').order_by('param')
    find('all').order_by('param').end()
    find('all').order_by('p1','p2').desc().limit(10,20)

Definition at line 194 of file orm.py.

Here is the call graph for this function:

◆ rep_sym()

def aestate.work.orm.AOrm.rep_sym (   self,
  sym = ',',
  rep = '' 
)
将最后一个参数包含的指定字符替换为指定字符

Definition at line 447 of file orm.py.

Here is the caller graph for this function:

◆ run()

QuerySet aestate.work.orm.AOrm.run (   self,
  need_sql = False,
  serializer = True 
)
最终执行任务

Definition at line 376 of file orm.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set()

def aestate.work.orm.AOrm.set (   self,
**  kwargs 
)
设置
example:
    update('table').set('param','value').end()
    update('table').set('param1','value1').where('param2=value2').end()

Definition at line 343 of file orm.py.

Here is the call graph for this function:

◆ top()

def aestate.work.orm.AOrm.top (   self)

Definition at line 112 of file orm.py.

Here is the call graph for this function:

◆ where()

def aestate.work.orm.AOrm.where (   self,
**  kwargs 
)
当....
example:
    find('ALL').where(param='%s') - 默认符号为等于 ==
    find('ALL').where(param='==%s')
    find('ALL').where(param='>%d')
    find('ALL').where(param='<%d')
    find('ALL').where(param='<=%d')
    find('ALL').where(param='>=%.2f')
    find('ALL').where(param='!=%.2f')
复杂语法:
    find('ALL').where(param='+%d/%d==%d')
    find('ALL').where(param='-%.2f*%d==12')
    find('ALL').where(param='*10-1==12')
    find('ALL').where(param='/10+1==12')

Definition at line 230 of file orm.py.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ __table_name__

aestate.work.orm.AOrm.__table_name__
private

Definition at line 107 of file orm.py.

◆ _result

aestate.work.orm.AOrm._result
private

Definition at line 110 of file orm.py.

◆ args

aestate.work.orm.AOrm.args

Definition at line 92 of file orm.py.

◆ exmode

aestate.work.orm.AOrm.exmode

Definition at line 91 of file orm.py.

◆ first_data

aestate.work.orm.AOrm.first_data

Definition at line 109 of file orm.py.

◆ params

aestate.work.orm.AOrm.params

Definition at line 93 of file orm.py.

◆ ParseUtil

aestate.work.orm.AOrm.ParseUtil

Definition at line 96 of file orm.py.

◆ repository

aestate.work.orm.AOrm.repository

Definition at line 104 of file orm.py.

◆ serializer

aestate.work.orm.AOrm.serializer

Definition at line 97 of file orm.py.

◆ sqlFields

aestate.work.orm.AOrm.sqlFields

Definition at line 94 of file orm.py.


The documentation for this class was generated from the following file: