Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Sqlite DateTime ÀàÐÍ ¶ÁÈ¡ºÍдÈë¸ñʽעÒâµÄÎÊÌâ

±¾ÎÄתÔØ×Ô http://www.tntserver.cn/article.asp?id=41
½ñÌìÓöµ½¸öÎÊÌâ.
Ê×ÏȲåÈëÒ»¸öDataTime¸ñʽµÄÊý¾Ý:
string sql="insert into [table] (date_time) values('" + date_time.ToString() + "'";
Ö´ÐÐÈçÉÏÃüÁî.²åÈëûÓб¨¸æ´íÎó.
µ«ÊÇ,ÎÒÓÖÓÃÒ»ÌõÃüÁî¶Áȡʱ:
string sql="select * from [table];
.....
IDataReader dr=cmd.ExecuteReader();
...
object obj=dr["data_time"];//ÔÚÕâÀï³ö´íÁË,˵ÊÇÎÞ·¨×ª»»ÎªDataTime¸ñʽ,×Ö·û´®²»ÕýÈ·
--------------------------------------------------------------------------------------------
ÎÒÕÒÁËÒ»ÌìµÄ½Ì³Ì,ÕÒÁËÒ»ÌìµÄgoogle.
´ð°¸ÊÇ:sqliteÓõÄÈ«Çòʱ¼äUTC,ÒªÓÃdatetime()º¯Êýת»»Èô¸É.
ÎÒÒ²ÊÔÁË,·¢ÏÖºÃÏñÔËÐеIJ»Ïñ½Ì³ÌÉÏ˵µÄÄÇÑù!
ʵÔÚû°ì·¨,À´Ó²µÄ°É,Ó²×ÅͷƤ¿´Ô´´úÂë°É.
ËûµÄ¼Ì³Ð¸ñʽ´óÖÂÈçÏÂ:
SqliteConvert-->SqliteBase-->Sqlite3
ÔÚSqliteConvertÖж¨ÒåÁËת»»¸ñʽ,ÉÏÃæ˵µÄºÜÃ÷°×,ĬÈÏDataTime¸ñʽΪ ISO8601
È»ºó,SqliteConnection Óõ½ÁËSqlite3.
ÎÒ¾ÍÑо¿ÁËSqliteConnectionµÄÔ´´úÂë,·¢ÏÖSqlite²»ÊÇÓõÄʲôȫÇòµÄUTCʱ¼ä.
Æäʵ¾ÍÊÇÓõĹú¼Ê±ê×¼ISO 8601±ê×¼.
ÄÇÎÒ¾Í×ÅÊÖ¿´Ôõô²ÅÄÜÈÃÎҵijÌÐòºÍsqlite¼æÈÝ.
ÎÒÉú³ÉµÄ×Ö·û´®ºÍsqliteµÄÓÐʲô²»Í¬.
×îºó¿´ÁËmsdnÉ϶Ôiso 8601µÄÃèÊö:(http://msdn.microsoft.com/zh-cn/library/ms187819.aspx)
¸ø³öÁË×Ö·û´®Ê¾Àý:
* 2004-05-23T14:25:10
* 2004-05-23T14:25:10.487
¶øÎÒÉú³ÉµÄ×Ö·û´® data_time.ToString()ºÍËûµÄÓÐÒ»¸ö²»Í¬µÄµØ·½.
¾ÍÊÇûÓÐÄǸöT....(ÆäʵÎÒÒ²²»Ã÷°×ÄǸöTÓÐʲô¹Ø¼ü×÷ÓÃ,·´ÕýAccess,MySql,MsSql¶¼Ã»ÕâÎÊÌâµÄ)
ÎÒÓÖÔÚÏë,Èç¹ûÎÒÓÃÒ»¸öT»áÈçºÎ?
¾Í³¢ÊÔ.ÓÃdata_time.ToString("s");ÕâÖÖ·½·¨×ª»»³É iso 8601±ê×¼×Ö·û´®¸ñʽ
½á¹ûÎÒ³Ôʺ³ÔÁ˸ö½´°åÍ·(ÎÞÎý»°,Òâ˼ÊÇÔËÆøºÃ),¾¹È»³É¹¦ÁË.
ÈçÏÂ:
string sql="insert into [table] (date_time)" values('" + date_time.ToString("s") + "'";
ÕâÑù,ÎÊÌâ¾Í½â¾öÁË,Ï£Íû´ó¼ÒÄܹ»¿´µ½´ËÌù,²¢·¢Ñï¹â´ó,µ½´¦Á÷´«,ÕâÑù²ÅÄÜ·¢Õ¹SqliteµÄÆÕ¼°ÂÊ.
¸½×¢:
ÎÒÆðÏÈÑо¿ÁËBBSMAXµÄSqliteÊý¾Ý¿â.ÎÒÈÏΪÕâ¸öÂÛ̳»áÓкõĽâ¾ö·½·¨.
µ«ÎÒ´íÁË.ÆäʵûÓÐ.bbsMaxÓÃÁËvarchar´úÌæDateTime¸ñʽ.
ÎÒÒ²ÕÕ×öÁË,µ«Êǵ±ÎÒÓõ½ select * from [table] where date_time > '2006-1-1' and date_time< '2008-1-1'
ÀàËÆÕâÑùµÄÓï¾ä,Ïë²éѯһ¸öÖмäµÄʱ¼äÀàÐÍʱ,Óï·¨´íÎó.


Ïà¹ØÎĵµ£º

Python sqlite3ºÍµ¥Ôª²âÊÔ

 
import os
import unittest # °üº¬µ¥Ôª²âÊÔÄ£¿é
import sqlite3 as sqlite # °üº¬sqlite3Ä£¿é
def get_db_path():
return "sqlite_testdb"
class TransactionTests(unittest.TestCase): # µ¥Ôª²âÊÔµÚÒ»²½:¡¡ÓÉTestCaseÅÉÉúÀà
def setUp(self): # µ¥Ôª²âÊÔ»·¾³ÅäÖÃ
......

sqlite³£¼ûÎÊÌâ

 (1) ÈçºÎ½¨Á¢×Ô¶¯Ôö³¤×Ö¶Î?
¼ò¶Ì»Ø´ð£ºÉùÃ÷Ϊ INTEGER PRIMARY KEY µÄÁн«»á×Ô¶¯Ôö³¤¡£
³¤Ò»µãµÄ´ð°¸£º Èç¹ûÄãÉùÃ÷±íµÄÒ»ÁÐΪ INTEGER PRIMARY KEY£¬ÄÇô£¬ ÿµ±ÄãÔÚ¸ÃÁÐÉϲåÈëÒ»NULLֵʱ£¬ NULL×Ô¶¯±»×ª»»ÎªÒ»¸ö±È¸ÃÁÐÖÐ×î´óÖµ´ó1µÄÒ»¸öÕûÊý£¬Èç¹û±íÊǿյģ¬ ½«»áÊÇ1¡£ (Èç¹ûÊÇ×î´ó¿ÉÄܵÄÖ÷¼ü 9223372036854775807 ......

SqliteʵÏÖĬÈÏʱ¼äΪµ±Ç°Ê±¼äÁеķ½·¨

    ÔÚSQL ServerÖУ¬´´½¨±í¸ñµÄʱºò£¬¶ÔÓÚʱ¼äÁÐÓÐʱºòÎÒÃÇ¿ÉÒÔ¸ù¾ÝÐèÒªÖ¸¶¨Ä¬ÈÏֵΪµ±Ç°Ê±¼ä£¨Ò²¾ÍÊÇ˵¼Ç¼Éú³ÉµÄʱºòÓÐĬÈϵÄʱ¼ä´Á£©¡£ÀýÈ磺
    create table log(
content varchar(256),
logtime datetime default getdate()
)
  
    È» ......

SQLiteÖеÄÈ«ÎÄËÑË÷

    °ÝGoogleµÄScott Hessͬ־Ëù´Í£¬SQLiteÒ²ÍƳöÁËÈ«ÎÄËÑË÷¹¦ÄÜ¡£
    SQLiteͨ¹ý½¨Á¢Ò»¸öÐéÄâ±í£¬½«ÊäÈëµÄÎÄ×Ö¸ù¾Ý¿Õ¸ñ¡¢±êµã·ûºÏµÈ¹æÔò½øÐзִʣ¬×éÖ¯³ÉÒ»¿ÃBÊ÷£¬ÒÔ´ËÀ´Ìá¸ßËÑË÷Ëٶȡ£
    ÈçºÎʹÓÃÕâÒ»¹¦ÄÜ£¬ÐÔÄÜÉÏÈçºÎ£¬´ó¼Ò¸÷×ÔÑо¿È¥°É¡£
    ÔÚÕâÀ ......

Qt£ºSQLite 3ÈëÃŽ̳Ì


OS X×Ô´Ó10.4ºó°ÑSQLiteÕâÌ×Ï൱³öÃûµÄÊý¾Ý¿âÈí¼þ£¬·Å½øÁË×÷ҵϵͳ¹¤¾ß¼¯Àï¡£OS X°ü×°µÄÊǵÚÈý°æµÄSQLite£¬ÓÖ³ÆSQLite3¡£ÕâÌ×Èí¼þÓм¸¸öÌØÉ«£º
Èí¼þÊôÓÚ¹«¹²²Æ£¨public domain£©£¬SQLite¿É˵ÊÇijÖÖ¡¸ÃÀµÂÈí¼þ¡¹£¨virtueware£©£¬×÷Õß±¾ÈË·ÅÆú×Å×÷Ȩ£¬¶ø¸øʹÓÃSQLiteµÄÈËÒÔϵġ¸×£¸£¡¹£¨blessing£©£º
May you do good an ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ