// sqlite½â¾öÖÐÎÄ·¾¶ÎÊÌâ,ÒÔÇ°Ñо¿sqliteʱºòÓöµ½µÄÖÐÎÄ·¾¶ÎÊÌâµÄ½â¾ö·½·¨
// AnsiString cbÖеÄ×Ö·û´®Àà,ÆäËü±àÒëÆ÷ÓÃstd::stringÌæ»»¼´¿É.
// MultiByteToWideCharÊÇwindows api
AnsiString fileName;
int strSize = fileName.Length();
char *ansi = new char[strSize+1];
wchar_t *unicode = new wchar_t[strSize+1];
StrCopy(ansi,fileName.c_str());
MultiByteToWideChar(CP_ACP,0,ansi,strSize,unicode,strSize);
sqlite3_open16(unicode,&Sqlitedb);
delete []ansi;
delete []unicode;
......
JavaÁ¬½ÓSQLiteÊý¾Ý¿âÏê½â ÏÂÔØSQLiteÊý¾Ý¿âµÄJDBC ÕâÀï¸ø³öÒ»¸öÖÐÎÄÕ¾µãµÄURL: ÉèÖû·¾³±äÁ¿£º ½«ÏÂÔص½µÄ°ü½âѹºóµÃµ½jar°ü sqlitejdbc-v033-nested.jar ·Åµ½%JAVA_HOME%\lib Ï£¬²¢ÇÒ½«ÆäÌí¼Óµ½classpathϵͳ»·¾³±äÁ¿ÖÐ,ÎÒµÄclasspathϵͳ»·¾³±äÁ¿ÏÖÔÚΪ: .;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\sqlitejdbc-v033-nested.jar
3 ÔÚÄãµÄ´úÂëÖÐÒýÓÃÕâ¸öÇý¶¯:
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:filename");//filenameΪÄãµÄSQLiteÊý¾ÝÃû³Æ
// ... use the database ...
conn.close();
ʾÀý³ÌÐòÈçÏ£º
import java.sql.*;
import org.sqlite.JDBC;
/**
* ÕâÊǸö·Ç³£¼òµ¥µÄSQLiteµÄJava³ÌÐò,
* ³ÌÐòÖд´½¨Êý¾Ý¿â¡¢´´½¨±í¡¢È»ºó²åÈëÊý¾Ý£¬
* ×îºó¶Á³öÊý¾ÝÏÔʾ³öÀ´
* @author zieckey (http://zieckey.cublog.cn)
*/
public class TestSQLite
{
public static void main(String[] args)
{
try
{
//Á¬½ÓSQLiteµÄJDBC
Class.forName("org.sqlite.JDBC");
......
JavaÁ¬½ÓSQLiteÊý¾Ý¿âÏê½â ÏÂÔØSQLiteÊý¾Ý¿âµÄJDBC ÕâÀï¸ø³öÒ»¸öÖÐÎÄÕ¾µãµÄURL: ÉèÖû·¾³±äÁ¿£º ½«ÏÂÔص½µÄ°ü½âѹºóµÃµ½jar°ü sqlitejdbc-v033-nested.jar ·Åµ½%JAVA_HOME%\lib Ï£¬²¢ÇÒ½«ÆäÌí¼Óµ½classpathϵͳ»·¾³±äÁ¿ÖÐ,ÎÒµÄclasspathϵͳ»·¾³±äÁ¿ÏÖÔÚΪ: .;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\sqlitejdbc-v033-nested.jar
3 ÔÚÄãµÄ´úÂëÖÐÒýÓÃÕâ¸öÇý¶¯:
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:filename");//filenameΪÄãµÄSQLiteÊý¾ÝÃû³Æ
// ... use the database ...
conn.close();
ʾÀý³ÌÐòÈçÏ£º
import java.sql.*;
import org.sqlite.JDBC;
/**
* ÕâÊǸö·Ç³£¼òµ¥µÄSQLiteµÄJava³ÌÐò,
* ³ÌÐòÖд´½¨Êý¾Ý¿â¡¢´´½¨±í¡¢È»ºó²åÈëÊý¾Ý£¬
* ×îºó¶Á³öÊý¾ÝÏÔʾ³öÀ´
* @author zieckey (http://zieckey.cublog.cn)
*/
public class TestSQLite
{
public static void main(String[] args)
{
try
{
//Á¬½ÓSQLiteµÄJDBC
Class.forName("org.sqlite.JDBC");
......
1. SQLite Database Browser ÊÇÒ»¸öSQLiteÊý¾Ý¿â¹ÜÀí¹¤¾ß¡£ÊÇ¿ªÔ´µÄ¡¢Ãâ·ÑµÄ¡£
Home Page
http://sqlitebrowser.sourceforge.net/
Download
http://sourceforge.net/project/showfiles.php?group_id=87946
Wiki
http://en.wikipedia.org/wiki/SQLite_Database_Browser
2. Ô½À´Ô½·¢ÏÖSQLiteµÄºÃÁË¡£ÇáÁ¿ÐÍ£¬ºËÐÄÎļþÒ»¸ö¾Í500¶àk£»×Ô°üº¬¡¢·Ç·þÎñʽ¡¢ÁãÅäÖá¢ÊÂÎñ»¯£¬¿çƽ̨£»¶øÇÒ£¬Ê¹Óúܷ½±ã£¬Ö§³Ö´ó²¿·ÖSQL£¬ÓïÑÔÓ¦¸Ã¸ü½Ó½üMysql µÄ¡£
.Net½áºÏSQLiteµÄ¿ª·¢Ò²ºÃÏñÔ½À´Ô½¶àÁË... ÎÒÃÇ¿ÉÒÔ´Ósourceforge»ñÈ¡SQLiteµÄADO.NET 2.0Êý¾ÝÌṩÕߣ¬ËäÈ»Ëü²¢²»ÊÇ×î¸ßЧµÄ°æ±¾£¨ËüÓÐÒ»¸öADO°ü×°²ãÒÔ¼°¸½´øµÄÎÞÓù¦ÄÜ£©£¬µ«ËüȷʵÊÇÒ»¸ö·Ç³£ÈÝÒ×ÉÏÊֵİ汾£¬¿ÉÄÜÖµµÃ³¤ÆÚʹÓᣠÏÖÔÚÒ»°ã.NetÏÂʹÓÃSQLite¶¼ÊÇÓõÄÕâ¸ö°æ±¾¡£
.NetÏÂʹÓÃSQLiteµÄÎÊÌâ½â¾öÁË£¬ÏÖÔÚÎÒÍƼöÁ½¿îSQLiteµÄµÄ¿ÉÊÓ»¯¹ÜÀíIDE£¬²»ÊÇ˵ÕâÁ½¿îIDEÊÇ×îºÃµÄ£¬Ö»ÊÇËüÃÇÊÇÃâ·ÑµÄ£¬¶øÇÒ¶¼²»Óð²×°£¬Ê¹Ó÷½±ã£¬¹¦ÄÜÒ²ËãÈ«¡£ËüÃÇÊÇ SQLite Administrator ºÍ SQLiteSpy¡£
SQLite Administrator ¿ÉÒ ......
SQLite ×÷Ϊһ¸öÇáÁ¿¼¶Ç¶ÈëʽÊý¾Ý¿â£¬»¹ÊǷdz£ºÃÓõġ£ÓêºÛ¼«Á¦ÍƼö~~~~~~
½ñÌìÓиöÅóÓѲâÊÔ SQLite£¬È»ºóµÃ³öµÄ½áÂÛÊÇ£ºSQLite ЧÂÊÌ«µÍ£¬ÅúÁ¿²åÈë1000Ìõ¼Ç¼£¬¾ÓÈ»ºÄʱ 2 ·ÖÖÓ£¡
ÏÂÃæÊÇËû·¢¸øÎҵIJâÊÔ´úÂë¡£ÎÒÔÎ~~~~~~
using System.Data;
using System.Data.Common;
using System.Data.SQLite;
// ´´½¨Êý¾Ý¿âÎļþ
File.Delete("test1.db3");
SQLiteConnection.CreateFile("test1.db3");
DbProviderFactory factory = SQLiteFactory.Instance;
using (DbConnection conn = factory.CreateConnection())
{
// Á¬½ÓÊý¾Ý¿â
conn.ConnectionString = "Data Source=test1.db3";
conn.Open();
// ´´½¨Êý¾Ý±í
string sql = "create table [test1] ([id] INTEGER PRIMARY KEY, [s] TEXT COLLATE NOCASE)";
DbCommand cmd = conn.CreateCommand();
cmd.Connection = conn;
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
// Ìí¼Ó²ÎÊý
cmd.Parameters.Add(cmd.CreateParameter());
......
SQLite ×÷Ϊһ¸öÇáÁ¿¼¶Ç¶ÈëʽÊý¾Ý¿â£¬»¹ÊǷdz£ºÃÓõġ£ÓêºÛ¼«Á¦ÍƼö~~~~~~
½ñÌìÓиöÅóÓѲâÊÔ SQLite£¬È»ºóµÃ³öµÄ½áÂÛÊÇ£ºSQLite ЧÂÊÌ«µÍ£¬ÅúÁ¿²åÈë1000Ìõ¼Ç¼£¬¾ÓÈ»ºÄʱ 2 ·ÖÖÓ£¡
ÏÂÃæÊÇËû·¢¸øÎҵIJâÊÔ´úÂë¡£ÎÒÔÎ~~~~~~
using System.Data;
using System.Data.Common;
using System.Data.SQLite;
// ´´½¨Êý¾Ý¿âÎļþ
File.Delete("test1.db3");
SQLiteConnection.CreateFile("test1.db3");
DbProviderFactory factory = SQLiteFactory.Instance;
using (DbConnection conn = factory.CreateConnection())
{
// Á¬½ÓÊý¾Ý¿â
conn.ConnectionString = "Data Source=test1.db3";
conn.Open();
// ´´½¨Êý¾Ý±í
string sql = "create table [test1] ([id] INTEGER PRIMARY KEY, [s] TEXT COLLATE NOCASE)";
DbCommand cmd = conn.CreateCommand();
cmd.Connection = conn;
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
// Ìí¼Ó²ÎÊý
cmd.Parameters.Add(cmd.CreateParameter());
......
import os
import unittest # °üº¬µ¥Ôª²âÊÔÄ£¿é
import sqlite3 as sqlite # °üº¬sqlite3Ä£¿é
def get_db_path():
return "sqlite_testdb"
class TransactionTests(unittest.TestCase): # µ¥Ôª²âÊÔµÚÒ»²½:¡¡ÓÉTestCaseÅÉÉúÀà
def setUp(self): # µ¥Ôª²âÊÔ»·¾³ÅäÖÃ
try:
os.remove(get_db_path())
except:
pass
self.con1 = sqlite.connect(get_db_path(), timeout=0.1) # Á¬½ÓÊý¾Ý¿â
self.cur1 = self.con1.cursor() # »ñÈ¡Óαê
self.con2 = sqlite.connect(get_db_path(), timeout=0.1)
self.cur2 = self.con2.cursor()
def tearDown(self): # µ¥Ôª²âÊÔ»·¾³Çå³ý
self.cur1.close() # ¹Ø±ÕÓαê
self.con1.close() # ¹Ø±ÕÁ¬½Ó
self.cur2.close()
self.con2.close()
os.unlink(get_db_path())
def CheckDMLdoesAutoCommitBefore(self):
self.cur1.execute("create table test(i)") # Ö´ÐÐSQL²éѯ
self.cur1.execute("insert into test(i) values (5 ......
import os
import unittest # °üº¬µ¥Ôª²âÊÔÄ£¿é
import sqlite3 as sqlite # °üº¬sqlite3Ä£¿é
def get_db_path():
return "sqlite_testdb"
class TransactionTests(unittest.TestCase): # µ¥Ôª²âÊÔµÚÒ»²½:¡¡ÓÉTestCaseÅÉÉúÀà
def setUp(self): # µ¥Ôª²âÊÔ»·¾³ÅäÖÃ
try:
os.remove(get_db_path())
except:
pass
self.con1 = sqlite.connect(get_db_path(), timeout=0.1) # Á¬½ÓÊý¾Ý¿â
self.cur1 = self.con1.cursor() # »ñÈ¡Óαê
self.con2 = sqlite.connect(get_db_path(), timeout=0.1)
self.cur2 = self.con2.cursor()
def tearDown(self): # µ¥Ôª²âÊÔ»·¾³Çå³ý
self.cur1.close() # ¹Ø±ÕÓαê
self.con1.close() # ¹Ø±ÕÁ¬½Ó
self.cur2.close()
self.con2.close()
os.unlink(get_db_path())
def CheckDMLdoesAutoCommitBefore(self):
self.cur1.execute("create table test(i)") # Ö´ÐÐSQL²éѯ
self.cur1.execute("insert into test(i) values (5 ......
1. Ô´´úÂëµÄ»ñÈ¡
sqliteÊÇÒ»¸ö¹¦ÄÜÇ¿´ó¡¢Ìå»ýСÔËËãËٶȿìµÄǶÈëʽÊý¾Ý¿â£¬²ÉÓÃÁËÈ«CÓïÑÔ·â×°£¬²¢ÌṩÁË°ËÊ®¶à¸öÃüÁî½Ó¿Ú£¬¿ÉÒÆÖ²ÐÔÇ¿£¬Ê¹Ó÷½±ã¡£
ÏÂÔصØÖ·£ºhttp://sqlite.org/download.html
sqliteÔ´´úÂ룺sqlite-3.6.17.tar.gz
2. sqliteÒÆÖ²µ½x86 for linux
l ½âѹÎļþ
//´´½¨Ò»¸öÎļþ¼Ð£¬½«Ô´´úÂë·ÅÔÚÕâ¸öÎļþ¼ÐÖС£
mkdir /work/sqlite
cp sqlite-3.6.17.tar.gz /work/sqlite
//½âѹÎļþ
cd /work/sqlite
tar xvzf sqlite-3.6.17.tar.gz
l ÅäÖÃ
//½¨Á¢x86Ŀ¼
mkdir sqlite_x86
//´ò¿ªÎļþ
cd sqlite-3.6.17
//ÅäÖÃsqlite
./configure --prefix=/work/sqlite/sqlite_x86 --disable-tcl
l ±àÒë
make
l °²×°
make install
l ²âÊÔ
µ±°²×°Íê³ÉÒԺ󣬰²×°Îļþ»á°²×°ÔÚ/work/sqlite/sqlite_x86Ŀ¼ÖУ¬Ò»ÖÖ²úÉúÁË£¬lib,includeºÍbinÈý¸öÎļþ¼Ð£¬·Ö±ðÊÇ¿âÎļþ£¬Í·ÎļþºÍ¿ÉÖ´ÐÐ ......