小型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我能知道文件的哪个条目正在被修改吗?   多线程Java并发线程   java抓取包含多个页面的多个字母标签的网站   为什么if语句不排除Java中的另一个if语句?   Java可序列化哈希映射到ByteArray以创建blob   JavaEclipseLombokBuilder添加新建议   java将文件路径数组转换为文件数组,并计算每个文件的大小   在Java8流中添加大小数   Bouncy Castle 1.46之前版本的java兼容性问题   无法在AWS设备场上运行安卓 Java Appium测试   java为什么不使用mavenwarplugin将键与“WEBINF/classes/METAINF/MANIFEST.MF”合并?   java如何在引用子类的成员时调用super()   找不到java TestFx无头MonoclePlatformFactory   java AbstractMethodError onClientSessionEvent和“缺少控制媒体的权限”   正则表达式如何使用JAVA在字符串的大写字母前插入空格?   我的Spring安全项目中的java BCrypt(Spring安全)   java在我的网站上查看小程序更新时遇到问题   java如何使用schedule方法