小型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:
````





欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java FirebaseInstanceId。getInstance()始终为空   linux Java执行文件错误   javaspringboot:如何使用Ajax在springboot和Thymeleaf中创建进度条?   java禁用在安卓上使用传单时启用setJavaScriptEnabled   java如何在主体中发布原始类型JSON数据?   消除JAVA While循环中的额外输出   如何在java中直接将基本数据类型分配给自定义类   java为什么addNode()方法返回编译错误“类型中的方法…不适用于参数…”,我该如何修复它?   java惰性合成可观察对象   eclipse Java Blackberry位图单击   java Android:AsyncTask对象[]无法在doInBackground中强制转换   java有没有办法重构或改进这段代码?   java如何使用系统以十六进制打印字节。出来普林顿?   多线程如何在我的java聊天室中调试“java.net.UnknownHostException”?   java如何从Google App Engine下载应用程序源文件   java如何在Spring Data Mongo的聚合$group中使用类似$dateToString   java IBM websphere application server未在MyEclipse8中启动。0