sqlite

Qt 的sqlite数据库的学习

坚强是说给别人听的谎言 提交于 2020-04-06 03:40:30
我们先了解一下基本的类:QSqlDatabase 提供数据库的连接操作,QSqlQuery是执行Sql语句的类,如: QSqlQuery query ( db ); query . exec ( "insert into person values(101, 'Danny', 'Young')" ); 下面是如何创建一个数据库以及一个数据表。 void myDatabase::createDB() { QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("music.db"); //创建数据库 if(!db.open()) { qDebug()<< "database is error"; //return; } else { qDebug()<<"database is ok"; //return; } QSqlQuery query(db); bool bsuccess = query.exec("create table person (id int primary key, " "firstname varchar(20), lastname varchar(20))"); //创建一个表 query.exec("insert into person values(101,

Delphi XE使用SQLite3

本小妞迷上赌 提交于 2020-04-03 10:25:41
用Delphi开发小程序,之前使用过Access数据库,但是由于Access依赖于office,感觉有些不太方便,研究一下Delphi使用SQLite3。 SQLite 是一款轻型的数据库,是遵守ACID的关系型数据库管理系统,它包含在一个相对小的C库中。 SQLite下载 官网下载页面 https://www.sqlite.org/download.html 找到下图内容,根据自己的开发环境选择下载32位的dll还是64位的dll,tools是一个能连接SQLite3的工具。 Delphi简单操作SQLite 将dll放入程序对应目录下, dll版本一定要和开发环境相对应 。 选择两个控件TFDConnection和TFDQuery, Name分别为FDConnection1和FDQuery1。 FDQuery1.SQLConnection选择FDConnection1。 简单操作,创建连接数据库,创建表,添加数据和查询数据 (1)创建连接数据库,数据库文件没有会自动创建 procedure TForm1.CreateDBClick(Sender: TObject); begin FDConnection1.DriverName := 'SQLite'; FDConnection1.Params.Add('DriverID=SQLite') ; FDConnection1

使用SQLite的感想

|▌冷眼眸甩不掉的悲伤 提交于 2020-03-30 06:49:10
  最近都在使用SQLite数据库,老实说这才是我使用的第三款数据库而已。使用它原因就应为它够轻量,而且性能挺不错。但使用久了也发现了一些问题。偶尔也会有怨言,但也不会骂SQLite是个破东西之类的,原因又几个:对SQLite的了解不过透彻,使用方式上总有些不妥;自己的资历尚浅,解决问题的能力有限;自己也没本事写出比SQLite更好的数据库。   在网上看了一下SQLite的适用场景。100000次/天访问量的网站,嵌入式设备和应用软件,应用程序文件格式等。但是读数据可时也会抛锁表的异常,SQLite的锁是粗粒度,这个对异常的处理不知如何是好;还有的就是数据库的损坏。Database disk image is malformed。网上说数据库造成数据库损坏的原因有三个 sqlite数据库在写入时断电等,导致数据库里的结果被破坏。 sqlite数据库所存的磁盘空间不够。 磁盘有坏磁道等   之前数据库的损坏估计是第一种原因。而当时又没有对数据进行什么备份。只能人工用.dump命令从损坏的数据库中把数据导出来。这个顺带也讲一下吧 在SQLite的命令模式中打开数据库,依次输入一下命令 sqlite> .mode insert sqlite> .output test.sql sqlite> .dump sqlite> .exit 当然不一定要”.exit”命令,按“Ctrl+C

Unity本地数据存储---Sqlite和JSON

喜你入骨 提交于 2020-03-27 22:19:15
2014-05-04更新 SqliteDatabase.cs这个文件的初始方法有问题,具体是如果指定URL已经存在了DB文件,就不会重新覆盖DB文件。 这导致我们修改之后的DB文件无法产生效果。 本人的解决办法是在游戏启动的界面,通过对比本地的Resources目录下的文件A,和玩家核心数据B里面的数据库版本号, 如果A>B,则判定本地的DB文件版本较老,需要更新。 具体代码请到目录SQLite篇下下载 2014-04-30更新 剔除了使用网络上烂大街的SQLite使用方法(原因android下无法读取数据),使用libSQLite3.so,通过DLLImport,在C#代码里直接调用C接口 这种原生调用SQLite的方式,我在pc、android上亲测无误,ios没测过,但是stackoverflow上有兄弟试过,没问题。园子的朋友如果可以测IOS的,欢迎提供结果 基本思路,游戏基础配置数据,比如怪物的属性、装备模板属性、关卡怪物等,使用SQLite(Unity插件SQLiteUnityKit- GitHub地址 ,推荐客户端 SQLite Expert Personal 3 ),管理方便 玩家核心数据(属性、装备、技能)使用JSON格式,加密保存在Application.persistentDataPath路径里,避免每次升级被覆盖 插件本地下载地址 Sqlite框架

C# - How to use ListView and SQLite database

北城余情 提交于 2020-03-26 04:07:32
问题 I'm trying to add some data from a SQLite database, inside a ListView. I'm having some difficulties as I want to insert all the data of the column and not a single record. TEST CODE: Form1.cs {Load} private void home_form_Load(object sender, EventArgs e) { listView1.Refresh(); listView1.View = View.Details; listView1.Columns.Add("ID"); listView1.Columns.Add("Grado"); listView1.Columns.Add("Cognome"); listView1.Columns.Add("Nome"); listView1.Columns.Add("Status"); } Form1.cs {menu_button

python sqlite3 record is not inserting into the database with a placeholder function

余生长醉 提交于 2020-03-25 17:44:11
问题 this code is not inserting my list(self.list2) into the database 'main.db'. I read the the following posts already and they all seem to use the idea of using join() to create # of place holders based on the length of the list. Dynamically creating a placeholder to insert many column values for a row in SQLite table Inserting to sqlite dynamically with Python 3 the code is running without errors. I tested the code by printing return (f"{', '.join('?' * len(input))}") and it prints "?, ?, ?, ?

How can I turn a list of strings into LIKE clauses in a Room Query?

狂风中的少年 提交于 2020-03-25 16:04:54
问题 I have a table called games that has a column called platforms , which contains a list of platform abbreviations. This is a list of all the platforms that specific game came out on. Here's an example of one of the cells in platforms : AMI,GG,SNES,CPC,AST,C64,SPEC,MAC,PS2,NES,3DO,ARC,XBGS,PS3N,PC,IPHN,DSI,HALC,PSPN,ANDR, The user can choose any number of platforms they wish to view games for. For example, they may choose to see games for the following platforms: SNES, MAC, PC So I need a way

How can I turn a list of strings into LIKE clauses in a Room Query?

ぐ巨炮叔叔 提交于 2020-03-25 16:04:26
问题 I have a table called games that has a column called platforms , which contains a list of platform abbreviations. This is a list of all the platforms that specific game came out on. Here's an example of one of the cells in platforms : AMI,GG,SNES,CPC,AST,C64,SPEC,MAC,PS2,NES,3DO,ARC,XBGS,PS3N,PC,IPHN,DSI,HALC,PSPN,ANDR, The user can choose any number of platforms they wish to view games for. For example, they may choose to see games for the following platforms: SNES, MAC, PC So I need a way

Hibernate not correctly saving an Object in the db (?, ?, ?, ?)

那年仲夏 提交于 2020-03-25 13:44:14
问题 Following from this question. (I'm using Hibernate 4.) As suggested in one of the answers I tried using the FeedbackDto-Feedback approach. Inside my RequestsController.java I have this: @PostMapping("/feedback") public void postFeedback(@RequestBody FeedbackDto feedbackDto) { Feedback feedback = new Feedback(new Product(feedbackDto.getProductId()), feedbackDto.getScore(), feedbackDto.isPreferred(), feedbackDto.getTextNote()); Session session = HibernateUtil.getSessionFactory().openSession();

How do I reference sqlite db column to use in update statement

两盒软妹~` 提交于 2020-03-25 07:41:13
问题 I am trying to update a datetime column in an android sqlite db to use international date format (yyyy-mm-dd) instead of the current format ( mm/dd/yyyy ). I want to use the sqlite date() function to reformat the current value of the column. I thought it would be as simple as the following: update tblename set thedate = date(thedate) but the above does not work. How would i write the sql statement to accomplish this? thanks patrick 回答1: DATE() doesn't understand your old date format. The