我的sqlite3数据库包含一个"collate"列约束.我把它放在桌子的架构中,以防止意外地忽略使用必要的整理.但是,这意味着sqlite3从命令行运行而不是从我的Python代码运行时,架构中引用的排序规则不存在,并且我无法使用点命令.
sqlite> .import data.txt table_name
Error: no such collation sequence: my_collation
Run Code Online (Sandbox Code Playgroud)
此外,从Python创建连接并添加所需的排序规则会遇到此问题:
connWithCollation.execute(".import data.txt table_name")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
sqlite3.OperationalError: near ".": syntax error
Run Code Online (Sandbox Code Playgroud)
execute它出现的功能不想通过sqlite3 dot命令.
如果没有必要的校对功能,如何执行sqlite3 dot命令?或者,我如何从Python执行sqlite3 dot命令?
我一直在使用SQLite数据库进行开发一段时间,我认为只查看生成的db文件的内容会很有用.有没有什么好的工具可以查看SQLite数据库文件和/或工具来运行针对它们的查询?
当我做某事的时候
sqlite.cursor.execute("SELECT * FROM foo")
result = sqlite.cursor.fetchone()
Run Code Online (Sandbox Code Playgroud)
我认为必须记住列似乎能够取出它们的顺序,例如
result[0] is id
result[1] is first_name
Run Code Online (Sandbox Code Playgroud)
有没有办法归还字典?所以我可以只使用结果['id']或类似的?
编号列的问题是,如果您编写代码然后插入一个列,您可能需要更改代码,例如first_name的result [1]现在可能是date_joined,因此必须更新所有代码...
我在SQLite数据库中插入时遇到异常
以下代码给出了例外情况:
mDbHelper.createUser("pablo","a","a","a","a");
Run Code Online (Sandbox Code Playgroud)
来自mDbHelper(MyDbAdapter)的代码:
private static final String USER_TABLE_CREATE = "CREATE TABLE user ( email varchar, password varchar, fullName varchar, mobilePhone varchar, mobileOperatingSystem varchar, PRIMARY KEY (email))";
public long createUser(String email, String password, String fullName, String mobilePhone, String mobileOperatingSystem)
{
ContentValues initialValues = new ContentValues();
initialValues.put("email",email);
initialValues.put("password",password);
initialValues.put("fullName",fullName);
initialValues.put("mobilePhone",mobilePhone);
initialValues.put("mobileOperatingSystem",mobileOperatingSystem);
return mDb.insert("user", null, initialValues);
}
Run Code Online (Sandbox Code Playgroud)
在最后一行创建了异常: return mDb.insert("user", null, initialValues);
我正在创建一个应用程序并尝试使用核心数据,因为它似乎是目标C批准的创建数据存储系统的方式.我使用的用例涉及"多对多"关系,就像您通常在标准SQL系统中看到的那样.我理解目标C不是数据库,而且工作方式不同.我还在这里查看了文档:
还有其他几个地方.然而,我仍然遇到麻烦.有人可以向我解释如果你有一个需要使用SQL交叉引用表的用例你会怎么做?例如:
经理人| 雇员
经理可能有几名员工,但员工可能还有几位经理.在SQL中,我创建了一个交叉引用表,然后使用它.
示例:http://www.tomjewett.com/dbdesign/dbdesign.php?page = manymany.php
有人可以解释你如何在核心数据中做到这一点?
根据核心数据文档,他们说:
"您使用两对多关系定义多对多关系.第一对多关系从第一个实体到第二个实体.第二个到多个关系从第二个实体到第一个实体.然后将每个设置为另一个的倒数.(如果您有数据库管理的背景,这引起您的关注,请不要担心:如果您使用SQLite存储,Core Data会自动为您创建中间连接表.) "
但是,除了"不担心"之外,我不知道这怎么可能起作用?
在SQL中,将Select into ...行复制到不同的(备份)表中.如果备份表具有不同的结构(或不同的列名),这可能吗?如果没有,实现这一目标的最佳方法是什么?
这是我想要做的:TableA有列a1,a2,a3.我想将此表中的一些行复制到另一个TableB具有列的表中b1,b2,b3,b4.内容a1进入b1,a2对b2等
我需要在sqlite数据库中计算欧氏距离.
除了为数学函数编写和加载动态库之外,有谁知道如何在sqlite中计算平方根?
我接近于在http://en.wikipedia.org/wiki/Fast_inverse_square_root中使用快速反平方根算法,尽管它现在可能变得比我需要的更有趣.
作为旁注,最好弄明白如何做电源(这是一个普遍的问题,而且编码比自己乘以一个数字更清晰).
谢谢,
西蒙娜
我在SQLite 1.0.94.1的Nuget包中遇到此错误.我对各种app.config部分进行了调整,有关此软件包以前版本的类似问题的帮助,但我无法使用它.下面是我在安装Nuget包后找到的app.config.我在安装之前删除了app.config.之后我才添加了连接字符串.
那么,问题出在哪里?
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<!--Added by me, the rest of the app.config was constructed by installing the SQLite package -->
<connectionStrings>
<add name="PrivateMessengerContext" connectionString="DataSource=|DataDirectory|\PrivateMessengerDb.db" providerName="System.Data.SQLite.EF6"/>
<add name="PasswordContext" connectionString="DataSource=|DataDirectory|\PasswordDb.db" providerName="System.Data.SQLite.EF6"/>
</connectionStrings>
<system.data>
<!--
NOTE: The extra "remove" element below is to prevent the design-time
support components within EF6 from selecting the legacy ADO.NET
provider for SQLite (i.e. the one without any EF6 support). It
appears to only …Run Code Online (Sandbox Code Playgroud) sqlite ×10
android ×2
python ×2
sql ×2
.net ×1
collation ×1
core-data ×1
database ×1
dataformat ×1
dictionary ×1
iphone ×1
math ×1
mysql ×1
objective-c ×1
sql-insert ×1