sqlite

Reset the id field in a table in a sqlite db in Rails

时光毁灭记忆、已成空白 提交于 2021-02-20 04:59:07
问题 Im using sqlite db in a sample rails application. From my users table, i have cleared all records using User.delete_all . But now whenever i insert a new record in the table using User.create , the id is starting at a value which is one more than the id of the last record which was there in the table. For example, if my table had 5 records and i cleared all, then when i do User.create, its starting at id 6. Is there any way i can make the id start from 1 again ? Thank You 回答1: Similar

How to set the 'PRAGMA foreign_keys = ON' statement with SQLitePCL

↘锁芯ラ 提交于 2021-02-20 04:37:51
问题 I have been using SQLitePCL (currently ver 3.8.7.2), and now decided to experiment with Delete and Update Cascade by turning on the Foreign Key constraint. I understand this feature is disabled by default and according to SQLite documentation, the constraint must be enabled separately for each database connection . The connection string only takes a database path (for SQLitePCL anyway) and doesn't allow more flexible composite connection string of the form data source=d:\foo\bar\mySqlite.db

12.Android-SQLiteOpenHelper使用

旧城冷巷雨未停 提交于 2021-02-20 03:00:37
1.SQLite 介绍 SQLite,是一款轻型的数据库,它的优缺点有如下: 轻量级,适合嵌入式设备,并且本身不依赖第三方的软件,使用它也不需要 “安装” 。 并发(包括多进程和多线程)读写方面的性能不太理想。可能会被写操作独占,从而导致其它读写操作阻塞或出错 2.SQLiteOpenHelper 介绍 为了在本地创建SQLite数据库,我们需要创建一个SQLiteOpenHelper的子类,这里取名的为 MyOpenHelper类 ,然后还要 写构造方法来初始化父类 、以及abstract修饰的抽象方法: onCreate(SQLiteDatabase)、onUpgrade(SQLiteDatabase,int,int). 2.1 为什么要创建SQLiteOpenHelper的子类(MyOpenHelper类)? 因为SQLiteOpenHelper不知道我们要创建的数据库是什么名字,以及表的内容,所以我们要 创建MyOpenHelper类 . 3.SQLiteOpenHelper 构造方法 构造方法用来创建数据库文件的,构造方法如下: public SQLiteOpenHelper(Context context, String name, CursorFactory factory, int version); // 第一个参数:上下文 // 第二个参数:数据库文件的名字

How to insert data into SQLite3 database with Python?

半世苍凉 提交于 2021-02-20 02:55:27
问题 I need to insert data into SQLite3 database using Python. I have written the query but it's not working as I expected. My code is below. conn = sqlite3.connect("db.sqlite3") cursor = conn.cursor() location_name = request.POST.get('lname') rname = request.POST.get('rname') seat = request.POST.get('seat') projector = request.POST.get('projector') video = request.POST.get('video') location_name = location_name[0:255] rname = rname[0:255] seat = seat[0:10] from_date = request.POST.get('from_date'

How to edit SQLite database values using kivy and RecycleView

大兔子大兔子 提交于 2021-02-19 08:44:09
问题 I'm trying to display an sqlite3 database in python using kivy. Tested out ikolim's solution here and it works as intended in displaying the database contents into the RecycleView's button labels: And when a button is pressed, a popup and edit function appears as intended: And it does edit the selected button's text as shown in the next screenshot.. : ..but not the sqlite database values. Would it be possible to reflect the changes the user makes inside the Kivy app to the values inside the

SQLAlchemy, reflection, different backends and table/column case insensitivity

▼魔方 西西 提交于 2021-02-19 07:53:09
问题 Intro: I'm writing web interface with SQLAlchemy reflection that supports multiple databases. It turns out that authors of application defined postgresql with lowercase tables/columns, eg. job.jobstatus while sqlite has mixed case, eg Job.JobStatus . I'm using DeclarativeReflectedBase from examples to combine reflection and declarative style. The issue: Configure SQLAlchemy to work with tables/columns case insensitive with reflection I have done so far: I have changed DeclarativeReflectedBase

SQLAlchemy, reflection, different backends and table/column case insensitivity

别说谁变了你拦得住时间么 提交于 2021-02-19 07:53:03
问题 Intro: I'm writing web interface with SQLAlchemy reflection that supports multiple databases. It turns out that authors of application defined postgresql with lowercase tables/columns, eg. job.jobstatus while sqlite has mixed case, eg Job.JobStatus . I'm using DeclarativeReflectedBase from examples to combine reflection and declarative style. The issue: Configure SQLAlchemy to work with tables/columns case insensitive with reflection I have done so far: I have changed DeclarativeReflectedBase

Splitting sqlite files for syncing

蹲街弑〆低调 提交于 2021-02-19 07:49:06
问题 I am writing an Android app that collects data from sensors and stores it in a local SQLite database. What I'd like to do is sync this data (read: upload) with a backend application (I am using Android's Sync Adapter for this). Since the data can be acquired during the sync process, I think it is reasonable to set the maximum size for the sqlite file to say 700 Kb (doesn't really matter), so the sync adapter will synchronise those 700 Kb files (via POST request) excluding the active one. And

sqlite.SQLiteException: near “s”: syntax error: because of apostrophe

杀马特。学长 韩版系。学妹 提交于 2021-02-19 07:14:26
问题 The song name that I want to insert it into my table contains a " ' " (apostrophe )so , there is an error when the request is excuted. How can I fix it Cursor pid = mDB.rawQuery("select Id FROM MusicPlayer WHERE "Path ='" + sname + "';", null); I am getting sname runtime so .. sname= /mnt/sdcard/Now Thats What I Call Music 85 [Bubanee]/16 - Let's Get Ready To Rhumble (100% Radio Mix) - PJ & Duncan.mp3 I get below error.. android.database.sqlite.SQLiteException: near "s": syntax error: , while

sqlite.SQLiteException: near “s”: syntax error: because of apostrophe

会有一股神秘感。 提交于 2021-02-19 07:13:34
问题 The song name that I want to insert it into my table contains a " ' " (apostrophe )so , there is an error when the request is excuted. How can I fix it Cursor pid = mDB.rawQuery("select Id FROM MusicPlayer WHERE "Path ='" + sname + "';", null); I am getting sname runtime so .. sname= /mnt/sdcard/Now Thats What I Call Music 85 [Bubanee]/16 - Let's Get Ready To Rhumble (100% Radio Mix) - PJ & Duncan.mp3 I get below error.. android.database.sqlite.SQLiteException: near "s": syntax error: , while