Android的OrmLite pre填充数据库 [英] Android OrmLite pre-populate database
问题描述
是否有可能与OrmLite创建一个SQL脚本文件轻松地填充数据的数据库?我做了一些搜索和无法拿出任何东西容易。我知道我可以创建数据的一些对象,我只是在寻找一个更清洁的方式。
Is it possible with OrmLite to create a sql script file to easily populate the database with data? I did some searching and couldn't come up with anything easy. I know I can create some objects with data, I'm just looking for a cleaner method.
我想创建一个脚本文件,打开AA阅读器的负载,并处理每一个文件作为原始SQL的executeRaw()方法。有什么想法?
I'm thinking create a script file, open a a reader at load, and process each file as raw SQL the executeRaw() method. Any thoughts?
推荐答案
好处一乔。我觉得你的 executeRaw()
的想法是接近,但使用 updateRaw()
代替。更新把手插入
,删除
和更新
语句。
Good one Joe. I think your idea of the executeRaw()
is close but use updateRaw()
instead. Update handles INSERT
, DELETE
, and UPDATE
statements.
http://ormlite.com/docs/raw-update
您应该叫 TableUtils
来首先创建您的模式,当然:
You should call TableUtils
to create your schema first of course:
http://ormlite.com/docs/tableUtils
希望这有助于。您可能需要使用邮件列表在未来的问题:
Hope this helps. You may want to use the mailing list for questions in the future:
http://groups.google.com/group/ormlite-user/
这篇关于Android的OrmLite pre填充数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!