精华内容
参与话题
问答
  • Sqllite

    2019-09-20 17:15:41
    Sqllite是什么? SQLite是一个进程内的库,实现了自给自足的、无服务器的、零配置的、事务性的 SQL 数据库引擎。它是一个零配置的数据库,这意味着与其他数据库一样,您不需要在系统中配置。 就像其他数据库,SQLite...

    Sqllite是什么?

    SQLite是一个进程内的库,实现了自给自足的、无服务器的、零配置的、事务性的 SQL 数据库引擎。它是一个零配置的数据库,这意味着与其他数据库一样,您不需要在系统中配置。

    就像其他数据库,SQLite 引擎不是一个独立的进程,可以按应用程序需求进行静态或动态连接。SQLite 直接访问其存储文件。

    为什么用Sqllite?

    1. 不需要一个单独的服务器进程或操作的系统(无服务器的)。

    2. SQLite 不需要配置,这意味着不需要安装或管理。

    3. 一个完整的 SQLite 数据库是存储在一个单一的跨平台的磁盘文件。

    4. SQLite 是非常小的,是轻量级的,完全配置时小于 400KiB,省略可选功能配置时小于250KiB。

    5. SQLite 是自给自足的,这意味着不需要任何外部的依赖。

    6. SQLite 事务是完全兼容 ACID 的,允许从多个进程或线程安全访问。

    7. SQLite 支持 SQL92(SQL2)标准的大多数查询语言的功能。

    8. SQLite 使用 ANSI-C 编写的,并提供了简单和易于使用的 API。

    9. SQLite 可在 UNIX(Linux, Mac OS-X, Android, iOS)和 Windows(Win32, WinCE, WinRT)中运行。

    Sqllite怎么用?

    我这里是SpringBoot与Sqllite的整合

    1,添加依赖

    		<!--sqllite-->
    		<dependency>
    			<groupId>org.xerial</groupId>
    			<artifactId>sqlite-jdbc</artifactId>
    			<version>3.23.1</version>
    		</dependency>
    

    2,连接数据库

    它连接到一个现有的数据库。如果数据库不存在,那么它就会被创建,最后将返回一个数据库对象。

    import java.sql.*;
    
    public class SQLiteJDBC{
      public static void main( String args[] ) {
        Connection c = null;
        try {
        	//加载驱动
          Class.forName("org.sqlite.JDBC");
          // 创建连接对象
          c = DriverManager.getConnection("jdbc:sqlite:test.db");
        } catch ( Exception e ) {
          System.err.println( e.getClass().getName() + ": " + e.getMessage() );
          System.exit(0);
        }
        System.out.println("Opened database successfully");
      }
    }
    

    2,增删改查

    
    try {
    //创建会话
     stmt = c.createStatement();
     		//建表
          String sql = "CREATE TABLE COMPANY " +
                       "(ID INT PRIMARY KEY     NOT NULL," +
                       " NAME           TEXT    NOT NULL, " + 
                       " AGE            INT     NOT NULL, " + 
                       " ADDRESS        CHAR(50), " + 
                       " SALARY         REAL)"; 
          stmt.executeUpdate(sql);
    
         	 //增
       	  String sql = "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) " +
                       "VALUES (1, 'Paul', 32, 'California', 20000.00 );"; 
          stmt.executeUpdate(sql);
          
          //查
    	  ResultSet rs = stmt.executeQuery( "SELECT * FROM COMPANY;" );
          while ( rs.next() ) {
             int id = rs.getInt("id");
             String  name = rs.getString("name");
             int age  = rs.getInt("age");
             String  address = rs.getString("address");
             float salary = rs.getFloat("salary");
             System.out.println( "ID = " + id );
             System.out.println( "NAME = " + name );
             System.out.println( "AGE = " + age );
             System.out.println( "ADDRESS = " + address );
             System.out.println( "SALARY = " + salary );
             System.out.println();
          }
          rs.close();
    
    		//改
     	  String sql = "UPDATE COMPANY set SALARY = 25000.00 where ID=1;";
          stmt.executeUpdate(sql);
          c.commit();
    
    		//删
     	  String sql = "DELETE from COMPANY where ID=2;";
          stmt.executeUpdate(sql);
          c.commit();
     } catch (SQLException e) {
                System.err.println( e.getClass().getName() + ": " + e.getMessage() );
                System.exit(0);
            }
    

    3,关闭连接

     	try {
                stmt.close();
                c.close();
            } catch (SQLException e) {
                System.err.println( e.getClass().getName() + ": " + e.getMessage() );
                System.exit(0);
            }
    

    Sqllite遇到的问题?

    1,提供一个SqlLite可视化工具:

    链接:https://pan.baidu.com/s/14KiFvoQmTKZVlVydEDeLkg
    提取码:yci2

    1,关于插入value是不是int及特殊字符的问题:

    1,插入非int如果出现问题,打印你插入的sql看是否value有引号,如果没有
    在插入时value外面再加引号,报错加转义字符 示例:

    String insertsql = "INSERT INTO aaa VALUES (" + sbrj.getId() + ",\"" + sbrj.getZcbi() + "\",\"" + sbrj.getRjlxcn() +
                        "\",\"" + sbrj.getRjmc() + "\",\"" + sbrj.getCskfscn() + "\"," + 0 + "," + 0 + "," + 0 + "," + null + ");"
    

    2,如果有特殊字符:
    https://blog.csdn.net/forlong401/article/details/11749829

    展开全文
  • sqllite

    2019-09-28 00:35:28
    <dependency> <groupId>org.xerial</groupId> <artifactId>sqlite-jdbc</artifactId> <version>3.8.11.2</version></dependency> ...去sql...

    <dependency>
        <groupId>org.xerial</groupId>
        <artifactId>sqlite-jdbc</artifactId>
        <version>3.8.11.2</version>
    </dependency>

     

     

    1 安装

    去sqlite主页http://www.sqlite.org/.跳转到下载也http://www.sqlite.org/download.html。源码下载sqlite-amalgamation-3.7.3.tar.gz

    我去的时候是3.7.3版现在估计升级了。

    进入下载目录,解压文件tar -zxvf sqlite-amalgamation-3.7.3.tar.gz.

    解压后生成sqlite-3.7.3目录. cd 进入sqlite-3.7.3。

    ./configure

    make

    sudo make install

    安装完成。

    2测试

    在任意目录下新建一个数据库,比如student ,

    命令: sqlite3 student

    出现如下提示:

     

    SQLite version 3.7.2
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    sqlite>

    输入.help可以看到命令列表。

    输入sql语句create table user(username text primary key, password text); 建一张user表

    输入sql语句insert into user values("tianyou121", "123"); 插入一个用户。

    输入sql语句select * from user; 可以查看user表.

    输入sql命令是记得结尾的';'号。

     

    简述:

    记录Spring配置sqlite

    1. <?xml version="1.0" encoding="UTF-8"?>  
    2. <!-- 指定Spring配置文件的Schema信息 -->  
    3. <beans xmlns="http://www.springframework.org/schema/beans"  
    4.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    5.     xmlns:aop="http://www.springframework.org/schema/aop"  
    6.     xmlns:tx="http://www.springframework.org/schema/tx"  
    7.     xsi:schemaLocation="http://www.springframework.org/schema/beans   
    8.     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  
    9.     http://www.springframework.org/schema/tx   
    10.     http://www.springframework.org/schema/tx/spring-tx-2.5.xsd  
    11.     http://www.springframework.org/schema/aop   
    12.     http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">  
    13.   
    14.   
    15.     <!-- 定义数据源Bean-->  
    16.     <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">   
    17.         <!-- 指定连接数据库的驱动 -->  
    18.         <property name="driverClassName" value="org.sqlite.JDBC" />  
    19.         <!-- 指定连接数据库的URL -->  
    20.         <property name="url" value="jdbc:sqlite:C:/Users/anialy/Desktop/workspace/MyProj/db/MY_DB" />  
    21.     </bean>  
    22.   
    23.       
    24.     <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">  
    25.         <property name="dataSource">  
    26.             <ref local="dataSource" />  
    27.         </property>  
    28.     </bean>  
    29.   
    30.       
    31.     <bean id="appDao" class="com.anialy.myproj.dao.AppDao">  
    32.        <property name="jdbcTemplate">    
    33.             <ref local="jdbcTemplate" />    
    34.         </property>    
    35.     </bean>  
    36.       
    37.     <bean id="versionDao" class="com.anialy.myproj.dao.VersionDao">  
    38.         <property name="jdbcTemplate">    
    39.             <ref local="jdbcTemplate" />    
    40.         </property>    
    41.     </bean>  
    42.       
    43. </beans>  

    在web.xml中添上
    1. <listener>  
    2.   <listener-class>org.springframework.web.context.ContextLoaderListener    
    3.     </listener-class>  
    4. </listener>  
    5. <context-param>  
    6.   <param-name>contextConfigLocation</param-name>  
    7.   <param-value>  
    8.       classpath:applicationContext-dao.xml  
    9.   </param-value>  
    10. </context-param>  


     

    转载于:https://www.cnblogs.com/zouhao510/p/5460433.html

    展开全文
  • SqlLite

    2019-09-02 15:11:25
    package ... import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase;...import android.s...
    package com.example.zjq.sql_11_5;
    
    import android.content.ContentValues;
    import android.content.Context;
    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.View;
    import android.widget.Button;
    
    import java.io.File;
    
    public class MainActivity extends AppCompatActivity {
    
        private String path="/data/data/com.example.zjq.sql_11_5/database";
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate( savedInstanceState );
            setContentView( R.layout.activity_main );
    
            Button btnCreateDB=findViewById( R.id.btn_creat_db );
            Button btnCreateTable=findViewById( R.id.btn_creat_table );
            Button btnInsert=findViewById( R.id.btn_insert );
            Button btnInsertSQL=findViewById( R.id.btn_insert_sql );
            Button btnDelete=findViewById( R.id.btn_delete );
            Button btnDeleteSQL=findViewById( R.id.btn_delete_sql );
            Button btnUpdate=findViewById( R.id.btn_update );
            Button btnUpdateSQL=findViewById( R.id.btn_update_sql );
            Button btnSelect=findViewById( R.id.btn_select );
            Button btnSelectSQL=findViewById( R.id.btn_select_sql );
            Button btnTransaction=findViewById( R.id.btn_transaction );
    
            ButtonListener listener=new ButtonListener();
            btnCreateDB.setOnClickListener( listener );
            btnCreateTable.setOnClickListener( listener );
            btnInsert.setOnClickListener( listener );
            btnInsertSQL.setOnClickListener( listener );
            btnDelete.setOnClickListener( listener );
            btnDeleteSQL.setOnClickListener( listener );
            btnUpdate.setOnClickListener( listener );
            btnUpdateSQL.setOnClickListener( listener );
            btnSelect.setOnClickListener( listener );
            btnSelectSQL.setOnClickListener( listener );
            btnTransaction.setOnClickListener( listener );
        }
        //自定义监听器类
        public  class ButtonListener implements View.OnClickListener{
    
            @Override
            public void onClick(View v) {
                switch (v.getId()){
                    case R.id.btn_creat_db:
                        {
    //                        127|generic_x86:/data/data/com.example.zjq.sql_11_5 # cd database
    //                        generic_x86:/data/data/com.example.zjq.sql_11_5/database # sqlite3 my.db
    //                        SQLite version 3.18.2 2017-07-21 07:56:09
    //                        Enter ".help" for usage hints.
    //                        sqlite>
    
                            SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase( path+"/my.db", null );
                            db.close();
                        }
                        break;
                    case R.id.btn_creat_table:
                    {
    
    //                    sqlite> .tables  显示当前表
    
    //                    sqlite> .schema company  查看表结构
    
    //                    sqlite>.help   帮助
    
    
                        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase( path+"/my.db", null );
                        String sql="CREATE TABLE COMPANY (" +
                                "ID INTEGER PRIMARY KEY AUTOINCREMENT,"
                                +"NAME TEXT NOT NULL,"
                                +"AGE INT NOT NULL," +
                                "ADDRESS CHAR(50)," +
                                "SALARY REAL)";
                        db.execSQL( sql );
                        db.close();
    
                    }
    
    
                        break;
                    case R.id.btn_insert:
                    {
    
                        //                    sqlite> select * from company;  查看表数据  注意分号
    
                        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase( path+"/my.db", null );
                        ContentValues values=new ContentValues(  );
                        //set 只能设置一个 add是加
                        values.put( "NAME","HanMeiMei" );
                        values.put( "AGE",19 );
                        values.put( "ADDRESS","HeBtu" );
                        values.put( "SALARY",3500);
                        db.insert("COMPANY",null, values );  //强制为空的字段
                        db.close();
                    }
                        break;
                    case R.id.btn_insert_sql: {
                        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase( path + "/my.db", null );
                        String sql = "INSERT INTO COMPANY(" +
                                "NAME,AGE,ADDRESS,SALARY)" +
                                "VALUES(" +
                                "'SunWuKong',500,'HuaGuoShan',13.48)";
                        db.execSQL( sql );
                        db.close();
                    }
    
                        break;
                    case R.id.btn_delete: {
                        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase( path + "/my.db", null );
    
                        String whereClause = "NAME=? ";
                        String[] whereArgs = {"SunWuKong"};
                        db.delete( "COMPANY",whereClause,whereArgs );
                        db.close();
                    }
    
                        break;
                    case R.id.btn_delete_sql:
                    {
                        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase( path+"/my.db", null );
                        String sql="DELETE FROM COMPANY WHERE NAME = 'HanMeiMei'";
                        db.execSQL( sql );
                        db.close();
                    }
                        break;
                    case R.id.btn_update:{
                        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase( path+"/my.db", null );
                        ContentValues values=new ContentValues(  );
                        values.put( "NAME","WuKong" );
                        String whereClause = "NAME=? ";
                        String[] whereArgs = {"SunWuKong"};
                        db.update( "COMPANY",values, whereClause,whereArgs);
                        db.close();
                    }
                        break;
                    case R.id.btn_update_sql:{
                        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase( path+"/my.db", null );
                        String sql="UPDATE  COMPANY SET NAME='HanMei' WHERE NAME='HanMeiMei'";
                        db.execSQL( sql );
                        db.close();
                    }
    
                        break;
                    case R.id.btn_select: //需要返回数据
                    {
    
                        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase( path+"/my.db", null );
                        Cursor cursor=db.query(
                                "COMPANY",null,null,
                                null,null,null,null );//select *
                        if (cursor.moveToFirst()){
    
                            do {
                                //取数据
                                int id=cursor.getInt( cursor.getColumnIndex( "ID" ) );
                                String name=cursor.getString( cursor.getColumnIndex( "NAME" ) );
                                int age=cursor.getInt(cursor.getColumnIndex( "AGE" ) );
                                String address=cursor.getString( cursor.getColumnIndex( "ADDRESS" ) );
                                Double salary= cursor.getDouble( cursor.getColumnIndex( "SALARY" ) );
    
                                Log.e( "text",id+"|"+name+"|"+age+"|"+address+"|"+salary );
    
                            }while (cursor.moveToNext());//没有数值时 返回假
    
                        }
    
                        db.close();
                    }
    
                        break;
                    case R.id.btn_select_sql:{
                        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase( path+"/my.db", null );
                        String sql="SELECT * FROM COMPANY "; //where id=? name=?
                        Cursor cursor=db.rawQuery( sql,null ) ; //查询需要的 rawQurey
                        if (cursor.moveToFirst()){
    
                            do {
                                //取数据
                                int id=cursor.getInt( cursor.getColumnIndex( "ID" ) );
                                String name=cursor.getString( cursor.getColumnIndex( "NAME" ) );
                                int age=cursor.getInt(cursor.getColumnIndex( "AGE" ) );
                                String address=cursor.getString( cursor.getColumnIndex( "ADDRESS" ) );
                                Double salary= cursor.getDouble( cursor.getColumnIndex( "SALARY" ) );
    
                                Log.e( "text",id+"|"+name+"|"+age+"|"+address+"|"+salary );
    
                            }while (cursor.moveToNext());//没有数值时 返回假
    
                        }
                        db.close();
    
                    }
                        break;
    
                    case R.id.btn_transaction:{
                        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase( path+"/my.db", null );
                        db.beginTransaction();
                        try {
                            Cursor cursor=db.query( "COMPANY",new String[]{"SALARY"},"NAME=?",new String[]{"HanMeiMei"},null,null,null );
                            double salary=0.0;
                            if (cursor.moveToFirst()){ //假设只有一条语句
                                salary =cursor.getDouble( cursor.getColumnIndex( "SALARY" ) );
                            }
                            ContentValues values=new ContentValues(  );
                            values.put( "SALARY", salary+2.5);
                            String whereClause = "NAME=? ";
                            String[] whereArgs = {"HanMeiMei"};
                            db.update( "COMPANY",values,whereClause,whereArgs );
    
                            //事务执行成功,才真正更新
                            db.setTransactionSuccessful();
    
                        }catch (Exception e){
                            Log.e( "test",e.toString() );
                        }finally {
                            db.endTransaction();
                        }
                        db.close();
                    }
                        break;
    
                }
            }
    
        }
    
    
    }
    
    
    展开全文
  • SQLlite

    2015-08-04 10:26:00
    http://blog.csdn.net/liuhe688/article/details/6712782   http://blog.sina.com.cn/s/blog_64aedc270100twbj.html

    http://blog.csdn.net/liuhe688/article/details/6712782

     

    http://blog.sina.com.cn/s/blog_64aedc270100twbj.html

    展开全文
  • SQLLite

    2015-04-11 22:23:00
    在程序运行过程中,要想操作(增删改查,CRUD)数据库中的数据,必须使用SQL语句 select、insert、update、delete、from、create、where、desc、order、by、group、table、alter、view、index ...
  • test_sqllite failure

    2020-12-05 12:24:20
    pypika/tests/dialects/test_sqllite.py:18: AssertionError _________________________________ SelectTests.test_bool_true_as_one _________________________________ import unittest self = <test_...
  • SQLLITE

    2014-01-26 22:34:32
    //创建数据库static sqlite3 *sqlite=nil; +(sqlite3*)openDB{  if (!sqlite) {  // DataBase *database=[[DataBase alloc]init];  // database;  NSString* fromPath=[[NSBundle
  • <div><p>iOS SqlLite has an edge case where if a field is read with a character such as "✌ " the returned value is ✌\u0000 where the last character (a space in this case) is replaced by \u...
  • gears sqllite adaptor

    2020-12-02 13:02:29
    <div><p>gears sqllite adaptor uses Lawnchair.extend. extend is not defined on Lawnchair. <p>Should be <code>Lawnchair.adapter('gears-sqlite', (function () { return { ... } }})());</code> ...
  • 易语言SQLlite数据库源码,SQLlite数据库,创建_库,打开_库,加_记录,到_首记录,到_尾记录,删除_记录,关闭_库,全部_关闭,取_字段名,取_字段位置,取_字段类型,取_字段数,取_记录数,取_记录索引,跳到指定记录,跳过记录,读...
  • <p>After a few seconds the app crashes with the error in the log attached - sqllite database locked code 5 <h2>Possible Fix <h2>Steps to Reproduce <p>Using configuration given, call ...
  • sqllite数据库

    2019-04-03 01:11:09
    NULL 博文链接:https://nwwolf.iteye.com/blog/1463602
  • sqlLite.rar

    2020-04-07 16:07:00
    sqlite工具,包含了32位的和64位的,随意供你选择。 安装之后操作也是比较简单的
  • sqllite 通讯录.zip

    2020-03-29 12:08:53
    帮别人做的期末考试作业,实现增删改查的通讯录,使用sqllite,介绍https://blog.csdn.net/qq_42733641/article/details/105176211
  • <div><p>I'm following precisely your ...t load plugin: sqlalchemy.dialects:sqllite</em></p> <p>Thank you in advance. Roberto</p><p>该提问来源于开源项目:miguelgrinberg/Flask-Migrate</p></div>
  • SQLLite provice/city

    2020-10-25 17:24:02
    city province city province city province this is a province and city resrouces
  • public partial class Login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { ... protected void BtnLogin_Click...这个问题怎么解决,F:\\网络编程.s3db是sqllite数据库路径
  • sqllite操作

    2019-10-04 08:56:34
    1、查询表 SELECTtype,name,btl_name,rootpage,sql FROM sqlite_master where type='table' and name='表名' 2、查询索引 SELECTtype,name,btl_name,rootpage,sql FROM sqlite_master where type='index' and ...

空空如也

1 2 3 4 5 ... 20
收藏数 2,313
精华内容 925
关键字:

sqllite