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. python基础 补漏

    输出 -----------定义变量类型 类型 集合 mongodb的用法和redis差不多一样的 NoSQL 数据库之一 https://www.runoob.com/python3/python- ...

  2. (K8s学习笔记八)Pod的扩缩容

    1.手动扩容机制 示例:对busybox-deployment手动扩缩容 apiVersion:apps/v1 kind: Deployment metadata: name: busybox-dep ...

  3. Linux下获取线程ID tid的方法

    使用Linux Redhat7编写代码的时候,需要使用 gettid() 函数获取线程ID.使用 man gettid 命令查看了一下,gettid()函数的头文件是 #include<sys/ ...

  4. DELL服务器基于centos7安装OMSA

    DELL服务器基于centos7安装OMSA 参考链接: https://www.cnblogs.com/sky-cheng/p/14951071.html https://www.dell.com/ ...

  5. centos7升级内核 ,wireguard优化

    一.centos7升级内核 uname -r 查看内核版本 升级前 升级后 参考链接: https://www.cnblogs.com/rick-zhang/p/14944510.html # 启用 ...

  6. [Github]获取github ID号

    [Github]获取github ID号 https://api.github.com/users/ + 你的账户名称 实例:我github账号叫iBoundary. https://api.gith ...

  7. 互联网公司IT系统架构进化之路

    一日,与一高手在茶馆聊天.他问道:在鞋厂剑派这两年,可习的什么高深的剑法?我不由一愣,细细想来,这两年每日练习的都是简单的劈砍动作和一些简练的套路.并没有去练什么高深的剑法.不过鞋厂剑派在江湖上也算小 ...

  8. MySQL之中文数据问题

    随笔记录方便自己和同路人查阅. #------------------------------------------------我是可耻的分割线--------------------------- ...

  9. python监控文件变化

    网址: https://blog.csdn.net/qq_40223983/article/details/102889329 起步在python中文件监控主要有两个库,一个是pyinotify,一个 ...

  10. 实现一个网页同时调用多个倒计时 jquery/js

    最近需要网页添加多个倒计时. 查阅网络,基本上都是千遍一律的不好用. 自己按需写了个.希望对大家有用. 有用请赞一个哦! //js2 var plugJs={ stamp:0, tid:1, stam ...