安裝django的時候會自動把sqlite資料庫安裝上,下面介紹如何操作sqlite資料庫:
1 進入你建立的目錄,在終端執行 sqlite3 dbname.db
2 進入後輸入.help可以檢視幫助文件
3 .tables 可以要看sqlite3中有哪些表
select * from tablename; 檢視資料
具體操作命令:
[root@10 src]# cd rietveld
[root@10 rietveld]# ls
apache.conf.example dev.db makefile readme settings.pyc todo upload.py.orig
codereview __init__.py manage.py rietveld_helper static updates
codereview.wsgi.example __init__.pyc patches settings.py templates upload.py
[root@10 rietveld]# sqlite3 dev.db
sqlite version 3.6.20
enter ".help" for instructions
enter sql statements terminated with a ";"
sqlite> .tables
auth_group codereview_issue
auth_group_permissions codereview_message
auth_message codereview_patch
auth_permission codereview_patchset
auth_user codereview_repository
auth_user_groups django_admin_log
auth_user_user_permissions django_content_type
codereview_account django_session
codereview_branch django_site
codereview_bucket gae2django_reftestmodel
codereview_comment gae2django_regressiontestmodel
codereview_content
sqlite> select * from auth_user;
1|root|||[email protected]|sha1$dac64$c7c81d89f0ff8f8cedefc95ad59a3849cf705f12|1|1|1|2012-09-20 23:43:39.161264|2012-09-20 03:54:33.257231
2|tao.lu|||[email protected]|sha1$fff77$7b4c631f4a6bf2b216dab658d853b3ef98d81906|0|1|0|2012-09-20 22:21:14|2012-09-20 22:20:56
sqlite> .help
.backup ?db? file backup db (default "main") to file
.bail on|off stop after hitting an error. default off
.databases list names and files of attached databases
.dump ?table? ... dump the database in an sql text format
if table specified, only dump tables matching
like pattern table.
.echo on|off turn command echo on or off
.exit exit this program
.explain on|off turn output mode suitable for explain on or off.
.genfkey ?options? options are:
--no-drop: do not drop old fkey triggers.
--ignore-errors: ignore tables with fkey errors
--exec: execute generated sql immediately
see file tool/genfkey.readme in the source
distribution for further information.
.header(s) on|off turn display of headers on or off
.help show this message
.import file table import data from file into table
.indices ?table? show names of all indices
if table specified, only show indices for tables
matching like pattern table.
.load file ?entry? load an extension library
.mode mode ?table? set output mode where mode is one of:
csv comma-separated values
column left-aligned columns. (see .width)
html html code
insert sql insert statements for table
line one value per line
list values delimited by .separator string
tabs tab-separated values
tcl tcl list elements
.nullvalue string print string in place of null values
.output filename send output to filename
.output stdout send output to the screen
.prompt main continue replace the standard prompts
.quit exit this program
.read filename execute sql in filename
.restore ?db? file restore content of db (default "main") from file
.schema ?table? show the create statements
if table specified, only show tables matching
like pattern table.
.separator string change separator used by output mode and .import
.show show the current values for various settings
.tables ?table? list names of tables
if table specified, only list tables matching
like pattern table.
.timeout ms try opening locked tables for ms milliseconds
.width num num ... set column widths for "column" mode
.timer on|off turn the cpu timer measurement on or off
sqlite>
資料庫操作 SQLite
sqlite 是乙個輕量級的關聯式資料庫。sqlite最初的設計目標是用於嵌入式系統,它占用資源非常少,在嵌入式裝置中,只需要幾百k的記憶體就夠了,目前應用於android ios windows phone等智慧型手機。ios 使用時sqlite,只需要加入 libsqlite3.dylib 依賴...
資料庫操作 SQLite
sqlite 是乙個輕量級的關聯式資料庫。sqlite最初的設計目標是用於嵌入式系統,它占用資源非常少,在嵌入式裝置中,只需要幾百k的記憶體就夠了,目前應用於android ios windows phone等智慧型手機。ios 使用時sqlite,只需要加入 libsqlite3.dylib 依賴...
SQLite資料庫操作
建立資料庫需要使用的api sqliteopenhelper 必須定義乙個構造方法 arg1 資料庫的名字 people.db arg2 游標工廠 通常直接傳人null,則系統會使用預設的工廠 arg3 資料庫版本號 從1開始 方便公升級使用,不斷設定更大的值會呼叫,onupgrade方法 publ...