using Newtonsoft.Json.Linq;
using System;
using System.Data.SQLite;
using System.IO; namespace @public
{
class Sqlite
{
public SQLiteConnection Sql;
public SQLiteConnection open()
{
//数据库地址 字符串
//这里将自己建立的数据文件的路径复制下来
string FilePath = @"Data Source= C:\Users\appaudit\Desktop\public\2B8Y1JYHJ789_076627A55E2452F901212F1E7C84FD21.db";
//new 数据库对象
Sql = new SQLiteConnection(FilePath);
//打开数据库
Sql.Open();
//返回数据库连接对象
return Sql;
} public SQLiteCommand command(string sql)
{
SQLiteCommand cmd = new SQLiteCommand(sql, open());
return cmd;
} public object Execute(string sql) //查询操作
{// select * from ludp_event order by id desc limit 1;
return command(sql).ExecuteScalar();
} public void SqlClose()
{
Sql.Close();//关闭数据库连接
}
static void Main(string[] args)
{
Console.ReadLine();
Sqlite sql = new Sqlite();
String obj = (string)sql.Execute("select event from ludp_event order by id desc limit 1");
Console.WriteLine("category: " + obj.GetType());
JObject jo = JObject.Parse(obj);
Console.WriteLine("category: " + jo.GetType());
Console.WriteLine("event_params " + jo["event_params"].ToString());
Console.ReadLine();
// 存到txt文件里
FileStream fs = new FileStream(@"c:\Users\appaudit\Desktop\public\Writesmartkeyevent.txt", FileMode.Append, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
try
{
sw.WriteLine(jo["event_params"][0]["value"]);
}
finally
{
if (sw != null) {
sw.Close();
fs.Close();
}
}
sql.SqlClose();
}
}
}

https://www.cnblogs.com/JiYF/p/11260178.html

用来进阶,我发布的时候还没看懂,留待以后

c# 连接SQLite 查询数据 写入txt文本的更多相关文章

  1. java 读取CSV数据并写入txt文本

    java 读取CSV数据并写入txt文本 package com.vfsd; import java.io.BufferedWriter; import java.io.File; import ja ...

  2. C#实现大数据量TXT文本数据快速高效去重

    原文 C#实现大数据量TXT文本数据快速高效去重 对几千万的TXT文本数据进行去重处理,查找其中重复的数据,并移除.尝试了各种方法,下属方法是目前尝试到最快的方法.以下代码将重复和不重复数据进行分文件 ...

  3. 一个简易的Python爬虫,将爬取到的数据写入txt文档中

    代码如下: import requests import re import os #url url = "http://wiki.akbfun48.com/index.php?title= ...

  4. python读取、写入txt文本内容

    转载:https://blog.csdn.net/qq_37828488/article/details/100024924 python常用的读取文件函数有三种read().readline().r ...

  5. Python中将变量按行写入txt文本中

    案例一: 讲数组a 循环写入名称为2.txt的文档中 # -*-coding:utf8-*- import requests from lxml import etree a=[1,2,3,4,5,6 ...

  6. Linux把查询结果写入到文本

    在Linux命令模式下,可以将查询结果写入文件.大概有两种方式,增量写入和覆盖写入. 增量写入: #iostat -m >> /tmp/iostat.txt 覆盖写入: #iostat - ...

  7. python连接 elasticsearch 查询数据,支持分页

    使用python连接es并执行最基本的查询 from elasticsearch import Elasticsearch es = Elasticsearch(["localhost:92 ...

  8. C 实现 创建多个txt文件,并以自然数列命名,然后将产生的十进制数据写入txt文档

    首先:以自然数列为txt命名. 这在C++中很容易实现,之间诶to_string(int num)+".txt"就可以,但是在C中没有string,只有char,那怎么办? 这里需 ...

  9. 使用Connector / Python连接MySQL/查询数据

    使用Connector / Python连接MySQL connect()构造函数创建到MySQL服务器的连接并返回一个 MySQLConnection对象 在python中有以下几种方法可以连接到M ...

  10. android: SQLite查询数据

    掌握了查询数据的方法之后,你也就将数据库的 CRUD 操 作全部学完了.不过千万不要因此而放松,因为查询数据也是在 CRUD 中最复杂的一种 操作. 我们都知道 SQL 的全称是 Structured ...

随机推荐

  1. 测试 SqlServer 数据库连接的简单办法

    1.创建一个文件, 命名为"dba.udl".  #保证后缀是.udl即可     2.双击它:     3.输入数据库地址"xxx.xxx.xxx.xxx,端口号&qu ...

  2. c++初始化和赋值的区别

    静态对象的声明及初始化不是赋值 声明(并缺省初始化)后再赋值 #include <iostream> #include <string> void fun(std::strin ...

  3. ubuntu 替换国内源,清华源

    参考 https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/ Ubuntu 的软件源配置文件是 /etc/apt/sources.list.将系统自带的该文 ...

  4. pgsql 自定义函数

    CREATE OR REPLACE FUNCTION test1(id INTEGER,id1 INTEGER) RETURNS INTEGER LANGUAGE plpgsql AS $$ decl ...

  5. 【STM32】SYSCLK配置|学习笔记

    一.RCC原理 所有stm32的外设都是挂载在相应的时钟上的,如下 挂载在AHB上的外设 挂载在APB1上的 APB2上的 所以RCC很重要,特别像TIM这种对时钟特别敏感的外设就必须把SYSCLK确 ...

  6. cv::eigen

    void TestEigen() { cv::Mat m = (cv::Mat_<float>(3, 3) << 1, 2, 3, 2, 5, 6, 3, 6, 7); cv: ...

  7. c#获取当前进程使用内存

    public static string GetMemory()        {            Process proc = Process.GetCurrentProcess();     ...

  8. ctfshow web入门41

    这个题过滤了$.+.-.^.~使得异或自增和取反构造字符都无法使用,同时甚至过滤了字母和数字. 但是特意留了个或运算符|. 由此我们可以尝试从ascii为0-255的字符中,找到用或运算能得到我们可用 ...

  9. AtCoder Beginner Contest 272 - G - Yet Another mod M

    随机 + 数论 题意 Submission #35524126 - AtCoder Beginner Contest 272 给一个长度为 \(n\;(1<=n<=5000)\) 的数组 ...

  10. spring cloud 配置文件加密解密

    1.底包 <dependency>   <groupId>org.springframework.security</groupId>   <artifact ...