我使用xcode与libsqlite3.dylib for sqlite,但是当我编译到设备时出现以下错误:
Ld /Users/user1319/Library/Developer/Xcode/DerivedData/Directory-app normal armv7
cd /Users/user1319/Desktop/app/app
setenv IPHONEOS_DEPLOYMENT_TARGET 5.0
setenv PATH "/Developer/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch armv7 -isysroot /Developer/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -L/Users/user1319/Library/Developer/Xcode/DerivedData/app_Directory-bnkhohrmxdhrusarswxeqvxlljct/Build/Products/Distribution-iphoneos -F/Users/user1319/Library/Developer/Xcode/DerivedData/app-bnkhohrmxdhrusarswxeqvxlljct/Build/Products/Distribution-iphoneos -filelist "/Users/user1319/Library/Developer/Xcode/DerivedData/app-bnkhohrmxdhrusarswxeqvxlljct/Build/Intermediates/app Directory.build/Distribution-iphoneos/app.build/Objects-normal/armv7/app.LinkFileList" -Xlinker -rpath -Xlinker / -dead_strip -miphoneos-version-min=5.0 -lsqlite3 -lsqlite3.0 -framework AddressBook -framework AddressBookUI -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/user1319/Library/Developer/Xcode/DerivedData/app-bnkhohrmxdhrusarswxeqvxlljct/Build/Products/Distribution-iphoneos/app.app/app
ld: warning: ignoring file /Developer/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/libsqlite3.dylib, missing required architecture armv7 in file
ld: warning: ignoring file /Developer/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/libsqlite3.0.dylib, missing required architecture armv7 in file
Undefined symbols for architecture armv7:
"_sqlite3_reset", referenced from:
-[FMDatabase executeUpdate:error:withArgumentsInArray:orVAList:] in FMDatabase.o
-[FMStatement …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Python(传统的,2.7)和SQLite(3)来编写书籍索引器.
代码归结为这一系列SQL语句:
'select count(*) from tag_dict' ()
/* [(30,)] */
'select count(*) from file_meta' ()
/* [(63613,)] */
'begin transaction' ()
'select id from archive where name=?' ('158326-158457.zip',)
/* [(20,)] */
'select id from file where name=? and archive=?' ('158328.fb2', 20)
/* [(122707,)] */
'delete from file_meta where file=?' (122707,)
'commit transaction' ()
# error: cannot commit - no transaction is active
Run Code Online (Sandbox Code Playgroud)
隔离级别为"DEFERRED"("EXCLUSIVE"并不是更好).
我试图使用connection.commit()而不是cursor.execute('commit') - 没有任何用处.
我有一个看起来像这样的查询:
SELECT
*
FROM table
WHERE
(col1, col2) in (
('col1_val1', 'col2_val1'),
('col1_val2', 'col2_val2'),
('col1_val3', 'col2_val3'),
)
Run Code Online (Sandbox Code Playgroud)
这适用于MySQL,但在sqlite3中失败并出现语法错误:
Error: near ",": syntax error
Run Code Online (Sandbox Code Playgroud)
如何将此查询重写为适用于sqlite3的等效查询?
我用这种方式编译代码:
g++ main.cpp -I sqlite3
Run Code Online (Sandbox Code Playgroud)
其中sqlite3是我从sqlite-amalgamation-3071100.zip收到的源文件的文件夹,-I是包含源的标志.
该存档包含:shell.c,sqlite3.c,sqlite3.h,sqlite3ext.h.
这是我收到的:
undefined reference to `sqlite3_open'
Run Code Online (Sandbox Code Playgroud)
该程序只包含#include和函数调用sqlite3_open(...);
如果我制作"sudo apt-get install libsqlite3-dev"并使用命令编译程序,我可以编译好
g++ main.cpp -lsqlite3
但我想解决这个问题,因为我不想在另一台计算机上安装一些库,我无法访问它!
我有以下select语句(使用sqlite3和pysqlite模块):
self.cursor.execute("SELECT precursor_id FROM MSMS_precursor "+
"JOIN spectrum ON spectrum_id = spectrum_spectrum_id "+
"WHERE spectrum_id = spectrum_spectrum_id "+
"AND ROUND(ion_mz,9) = ? AND ROUND(scan_start_time,4) = ? "+
"AND msrun_msrun_id = ?", select_inputValues)
Run Code Online (Sandbox Code Playgroud)
在Python中运行时需要55秒.在SQLite命令行上直接运行它只需要15ms.现在,我注意到,当它在这一步中时,Python程序进入不间断的睡眠状态(31283 ndeklein 18 0 126m 24m 3192 D 1.0 0.0 2:02.50 python顶部输出中的D),并且它从100%CPU下降到大约1%的CPU.现在我在这个查询中注意到了,在运行我在这里询问的查询时,我也查看了顶部输出.在此期间,顶部还显示它进入不间断的睡眠,虽然它在R和D之间来回切换并且仅减慢到大约50%(它根据D或R状态是否波动).
所以现在我认为这正在减慢我的查询速度(如果不间断睡眠与程序速度无关,请纠正我).如果是这样,我怎样才能确保程序不进入这种状态?
使用Python返回的EXPLAIN QUERY PLAN:
(0, 0, 1, u'SCAN TABLE spectrum (~50000 rows)')
Run Code Online (Sandbox Code Playgroud)
使用sqlite的命令行返回EXPLAIN QUERY PLAN:
0|0|1|SCAN TABLE spectrum (~50000 rows)
0|1|0|SEARCH TABLE MSMS_precursor USING INDEX fk_MSMS_precursor_spectrum_spectrum_id_1 (spectrum_spectrum_id=?) (~2 rows) …Run Code Online (Sandbox Code Playgroud) 我不得不搜索关于这些错误的很多帖子,但我仍然无法解决问题.这是我的代码,谁能帮助我看看出了什么问题?
- (void) copyDatabaseIfNeeded {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"SQL.sqlite"];
if (sqlite3_open([path UTF8String], &newDBconnection) == SQLITE_OK)
{
NSLog(@"Database opened successfully");
if(updateStmt == nil) {
NSString *updStmt = [NSString stringWithFormat: @"UPDATE Coffee SET CoffeeName = '500 Plus', Price = '1.40' Where CoffeeID= '3'"];
const char *mupdate_stmt = [updStmt UTF8String];
if(sqlite3_prepare_v2(newDBconnection, mupdate_stmt, -1, &updateStmt, NULL) != SQLITE_OK){
NSAssert1(0, @"Error while creating update statement. '%s'", sqlite3_errmsg(newDBconnection));
} else {
NSLog(@"Update successful");
} …Run Code Online (Sandbox Code Playgroud) 背景
我们正在使用System Center 2012在运行Windows 8 Enterprise x64的领域中将Windows 8 Metro风格的应用程序部署到三星平板电脑.平板连接到域并具有持久的DirectAccess连接,允许System Center将应用程序和更新推送到设备.
我们必须将我们的应用程序部署到现场可能有数百台设备,这就是我们进入System Center路线的原因.使用组策略在每个设备上安装代码签名证书.要部署应用程序,只需提供包输出并指定要安装它的设备集合.该应用程序只需几分钟即可显示在设备上.
我们遇到的问题是,当System Center部署我们的应用程序时,SQLite依赖关系丢失,我们的数据访问都不起作用.
关于我们的项目
我们的应用程序是一个使用SQLite作为后端的WinJS应用程序.但是,我们所有的数据访问代码都在WinJS项目引用的C#WinMD项目中.我们使用sqlite-net库与SQLite交谈 - 我们在C#项目中包含了它的源代码.
在Visual Studio中,我们安装了SQL Run for Windows Runtime扩展,如Tim Heuer的文章中所述.Metro应用程序引用了这个.
使用其他部署方法进行测试
当您在本地调试或运行它时,应用程序的SQLite数据访问工作正常 - 在Debug/Release和x86/x64中.
应用程序打包过程提供了一个PowerShell脚本,您可以根据需要使用该脚本来安装应用程序和开发人员许可证.使用PowerShell脚本安装我们的应用程序时,SQLite数据访问也可以正常工作.通过打包和安装应用程序的Debug/Release和x86/x64版本来验证这一点.
故障排除
当应用程序首次尝试使用SQLite时,我们会看到一个关于它无法找到sqlite3.dll的异常.
我们已经尝试/验证了以下内容:
更新 问题是System Center在部署SQLite库所需的Visual C++运行时库依赖项时遇到问题.所以不幸的是,这不再是一个编程问题了.我们正在获得一些帮助,我将发布修复程序.
我正在研究android项目.我使用了sqlite数据库.我在数据库中有表.我创建了databasehelper类.我想计算特定表中的记录数.我怎么能实现这个目标?任何帮助将不胜感激?
我有一个我无法弄清楚的记忆问题.我有一个类来完成我的所有数据库检索工作.我遇到的错误如下:
android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. # Open Cursors=733 (# cursors opened by this proc=733)
Run Code Online (Sandbox Code Playgroud)
执行此操作时发生内存分配错误:
mDatabaseInterface.getGraphForLevel(level);
Run Code Online (Sandbox Code Playgroud)
我知道这是一个泄漏,因为我大约每2.5秒调用一次这种方法,并且5或6个第一次调用很容易通过.现在这里是我的DatabaseInterface类中的方法:
public Graph getGraphForLevel(Level level) {
//get the nodes
ArrayList<Node> nodes = new ArrayList<Node>(Arrays.asList(this.getNodesWithLevel(level)));
//get the edges
ArrayList<Edge> edges = new ArrayList<Edge>(Arrays.asList(this.getEdgesWithNodes(nodes)));
return new Graph(nodes, edges);
}
public Node[] getNodesWithLevel(Level level) {
List<Node> l = new ArrayList<Node>();
Cursor cursor = mDatabase.query("nodes", null,
"level = " + wrapSql(String.valueOf(level.getId())), null, null, null, null);
while (cursor.moveToNext()) {
l.add(parseNodeFromCursor(cursor));
}
cursor.close();
return l.toArray(new Node[l.size()]); …Run Code Online (Sandbox Code Playgroud) 我正在尝试从我的数据库中检索信息.
我有像Lim Won Mong和的话Limited.
如果我做我的查询,SELECT name FROM memberdb WHERE name LIKE '%LIM%'时,会显示这两个Lim Won Mong和Limited我只希望从数据中Lim Won Mong.
我应该如何重写我的查询?
sqlite ×10
android ×2
python ×2
sql ×2
c++ ×1
commit ×1
compilation ×1
cursor ×1
g++ ×1
linux ×1
memory ×1
memory-leaks ×1
objective-c ×1
performance ×1
sleep ×1
sql-like ×1
transactions ×1
windows-8 ×1
winjs ×1
xcode ×1
xcode4 ×1