小型python2/3模块,便于处理表,并将表导入/导出到/从sql数据库和xml文件
sql-xml-table的Python项目详细描述
#sql_xml_table
一个允许您轻松创建和使用表的对象,同时还可以将表从/导出到sql数据库或xml文件,它可以作为在xml文件和sql数据库之间发送数据和ford的方式。
````
python
>;从sql_xml_table import table
````
python
table=table('anims')
````
然后需要使用agregar_column a(add_column)方法添加列,可以使用各种关键字参数:
-campo(field):字段名您不想导出到数据库后者。
-defento(默认值):如果在添加行时没有列,则为列设置默认值
-还有其他3个列,但它们仅用于数据库设置,实际上不起作用,例如:
````
python
table.agregar_columna(campo=“name”,tipo=“str”)
table.agregar_columna(campo=“year”,tipo=“date”)
但如果您不关心日期
table.agregar_columna(campo'priority',tipo'int')
````
python
table+=('cat',日期(1998,1,1),1)
table+={'year':日期(1998,1,1),'priority':2,名称:'fish'}
python
file=os.path.abspath(os.path.join(os.path.dirname('anials.xml'))
table.exportar_xml()
table.escribir_xml(file)
```
table.exportar_xml(file)table.escribribir/>```35;!python
table.importar_xml(file,tipo'archivo'archivo')
archivo是指file
```
```
python
对于表中的行:
如果行['id']==2:
行['name']+=''+行['priority']
行['priority']=none
打印(表)
``````
python
n=0
nmax=1
对于表中的行:
if row['id']%2==0:
del table[row]
n+=1
if n>;=nmax:break
print(table)
```
此示例假定列名为'id',但可以替换width row.pos,例如。
``
``
``
python
if row.pos==2:
````
一个允许您轻松创建和使用表的对象,同时还可以将表从/导出到sql数据库或xml文件,它可以作为在xml文件和sql数据库之间发送数据和ford的方式。
````
python
>;从sql_xml_table import table
````
python
table=table('anims')
````
然后需要使用agregar_column a(add_column)方法添加列,可以使用各种关键字参数:
-campo(field):字段名您不想导出到数据库后者。
-defento(默认值):如果在添加行时没有列,则为列设置默认值
-还有其他3个列,但它们仅用于数据库设置,实际上不起作用,例如:
````
python
table.agregar_columna(campo=“name”,tipo=“str”)
table.agregar_columna(campo=“year”,tipo=“date”)
但如果您不关心日期
table.agregar_columna(campo'priority',tipo'int')
````
python
table+=('cat',日期(1998,1,1),1)
table+={'year':日期(1998,1,1),'priority':2,名称:'fish'}
python
file=os.path.abspath(os.path.join(os.path.dirname('anials.xml'))
table.exportar_xml()
table.escribir_xml(file)
```
table.importar_xml(file,tipo'archivo'archivo')
archivo是指file
```
```
python
对于表中的行:
如果行['id']==2:
行['name']+=''+行['priority']
行['priority']=none
打印(表)
``````
python
n=0
nmax=1
对于表中的行:
if row['id']%2==0:
del table[row]
n+=1
if n>;=nmax:break
print(table)
```
此示例假定列名为'id',但可以替换width row.pos,例如。
``
``
``
python
if row.pos==2:
````