sqlite

Linux下编译支持SQLite3加密扩展

不问归期 提交于 2020-12-06 02:28:51
自PHP 5.3.0起默认启用SQLite3扩展,但是由于SQLite 3 开源版不带加密功能,如果想使用加密功能需要用他的商业版本。这导致PHP默认的SQLite扩展本身是不支持加密功能,只预留了相关的接口,详见官方文档介绍: An optional encryption key used when encrypting and decrypting an SQLite database. If the SQLite encryption module is not installed, this parameter will have no effect. 但是如果项目需要用到SQLite,如果不加密,对安全多多少少有一点影响。还好SQLite本身有预留加密的接口,许多爱好者就基于这个接口,实现了加密功能。 目前比较有知名度的分别是: wxsqlite3 和 sqlcipher ,其中sqlcipher官方有 文档 介绍如何实现php的加密SQLite3扩展,而wxsqlite3没有,不过目前知名的数据库管理工具Navicat使用的是wxsqlite3的库实现SQLite3的加密连接,所以为了后续维护的方便,故打算使用wxsqlite3。 扩展编译教程 首先你需要确保你没有将SQLite3扩展加入php主程序(编译时使用 --without-sqlite3 禁用 SQLite3

SQLite strings with NUL

守給你的承諾、 提交于 2020-12-05 11:09:22
问题 Can strings in SQLite 3 include NUL characters? If the answer to 1 is "yes", how can they be written in SQL queries? SQLite doesn't seem to have chr or char functions. 回答1: In general, no - SQLite internally is not 8-bit clean, probably due to its Tcl heritage. While NULs do not cause corruption problems, SQLite typically stops processing strings at the first embedded NUL character. This is true even for operators such as GLOB. For instance, you cannot match a BLOB column with GLOB when you

Convert Sqlite BigInt to Date

落爺英雄遲暮 提交于 2020-12-05 06:36:39
问题 I have a Sqlite database that I am using as an ado.net job store for my Quartz.net scheduler jobs. In one table, a column called START_TIME is of type big int. Is there a way to cast or convert a bigint to a date value? I would like to be able to query the database to see which jobs are scheduled at what date/time and a value such as 633869892000000000 is meaningless. Thanks! 回答1: This seemed to work for me; select datetime(DateColumn/10000000 - 62135596800, 'unixepoch') from YourTable

Foreign Key constraint doesn't work

时光总嘲笑我的痴心妄想 提交于 2020-12-04 14:30:33
问题 I have two tables, theme and quiz , here is their definition: CREATE TABLE "theme" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , "nom" VARCHAR NOT NULL ); CREATE TABLE quiz( id INTEGER PRIMARY KEY, nom VARCHAR(256) NOT NULL, theme INTEGER NOT NULL, niveau INTEGER NOT NULL, pass INTEGER DEFAULT 1 NOT NULL, jok INTEGER DEFAULT 1 NOT NULL, etat INTEGER DEFAULT 0 NOT NULL, FOREIGN KEY (theme) REFERENCES theme(id) ); The field id (the primary key) in the table theme is a Foreign Key in the

Foreign Key constraint doesn't work

五迷三道 提交于 2020-12-04 14:28:48
问题 I have two tables, theme and quiz , here is their definition: CREATE TABLE "theme" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , "nom" VARCHAR NOT NULL ); CREATE TABLE quiz( id INTEGER PRIMARY KEY, nom VARCHAR(256) NOT NULL, theme INTEGER NOT NULL, niveau INTEGER NOT NULL, pass INTEGER DEFAULT 1 NOT NULL, jok INTEGER DEFAULT 1 NOT NULL, etat INTEGER DEFAULT 0 NOT NULL, FOREIGN KEY (theme) REFERENCES theme(id) ); The field id (the primary key) in the table theme is a Foreign Key in the

Django连接mysql

a 夏天 提交于 2020-12-04 06:17:04
一、创建数据库   1、打开命令行工具,连接mysql数据库 mysql -u 用户名 -p 密码   2、创建数据库(mysql命令不区分大小写) CREATE DATABASE 数据库名字; 二、Django连接数据库   1、找到setting.py文件,修改配置 INSTALLED_APPS = [ ' django.contrib.admin ' , ' django.contrib.auth ' , ' django.contrib.contenttypes ' , ' django.contrib.sessions ' , ' django.contrib.messages ' , ' django.contrib.staticfiles ' , ' polls ' ] DATABASES = { # 'default': { # 'ENGINE': 'django.db.backends.sqlite3', # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), # } ' default ' : { ' ENGINE ' : ' django.db.backends.mysql ' , ' NAME ' : ' test1 ' , ' USER ' : ' root ' , ' PASSWORD ' : '

SQLite 3 Database with Django

不问归期 提交于 2020-12-03 07:35:41
问题 I am stuck on Django Documentation tutorial on displaying SQLite table. " If you’re interested, run the command-line client for your database and type \dt (PostgreSQL), SHOW TABLES; (MySQL), or .schema (SQLite) to display the tables Django created. " I have created a project named mysite. Location : C:\Python34\Scripts\mysite Inside mysite , there are mysite folder, db.sqlite3 , and manage.py . I opened command prompt and navigate to C:\Python34\Scripts\mysite and I type .schema and it

difference between pandas read sql query and read sql table

天大地大妈咪最大 提交于 2020-12-02 08:07:07
问题 Is there a difference in relation to time execution between this two commands : import pandas as pd df=pd.read_sql_query('SELECT * FROM TABLE',conn) df=pd.read_sql_table(TABLE, conn) Thank you for your help 回答1: I don't think you will notice this difference. Here is a source code for both functions: In [398]: pd.read_sql_query?? Signature: pd.read_sql_query(sql, con, index_col=None, coerce_float=True, params=None, parse_dates=None, chunksize=None) Source: def read_sql_query(sql, con, index

How to use the latest sqlite3 version in python

寵の児 提交于 2020-12-02 07:22:32
问题 I need to use sqlite version 3.8 or higher with python in Amazon Linux. I updated my sqlite installation to the latest version: $ sqlite3 -version 3.22.0 2018-01-22 18:45:57 0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2171d I also updated my pysqlite version pip install --upgrade pysqlite However, my pysqlite still only seems to support sqlite version 3.7: $ python >>> import sqlite3 >>> sqlite3.version '2.6.0' >>> sqlite3.sqlite_version '3.7.17' >>> >>> from pysqlite2 import

How to use the latest sqlite3 version in python

半城伤御伤魂 提交于 2020-12-02 07:20:29
问题 I need to use sqlite version 3.8 or higher with python in Amazon Linux. I updated my sqlite installation to the latest version: $ sqlite3 -version 3.22.0 2018-01-22 18:45:57 0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2171d I also updated my pysqlite version pip install --upgrade pysqlite However, my pysqlite still only seems to support sqlite version 3.7: $ python >>> import sqlite3 >>> sqlite3.version '2.6.0' >>> sqlite3.sqlite_version '3.7.17' >>> >>> from pysqlite2 import