ProcessDB实时/时序数据库——C/C++操作数据库对象
目录
前言
一、数据库字段介绍
二、新增数据库
三、删除数据库
四、修改数据库
五、查询数据库
前言
上文已经介绍C/C++使用ProcessDB的基本操作,本文将针对数据库的相关操作进行介绍
一、数据库字段介绍
字段 | 注释 |
id | 数据库id |
name | 数据库名 |
desc | 数据库描述 |
二、新增数据库
// ProcessDB_API_TEST.cpp : ProcessDB数据库示例
//#include <iostream>
#include <string>
#include <stdio.h>
#include <time.h>
#include <conio.h>
#include "processdb_v2.h"
using namespace std;int main(int argc, char* argv[])
{int res = 0;EBASE ebase = { 0 };/* 初始化连接控制块 */res = ebase2_init(&ebase);if (0 != res){cout << "ebase2_init failed !" << endl;getchar();exit(1);}/*设置超时时间*/int timeout = 30;ebase2_set_options(&ebase, EBASE_CONNECTION_TIMEOUT, &timeout);/* 建立连接 */res = ebase2_connect(&ebase, "127.0.0.1", 8301, "root", "root");if (0 != res){cout << "login failed, \n";getchar();exit(1);}/* 添加数据库 */res = ebase2_add_database(&ebase, "D99", "Description");if (res != 0){cout << "ebase2_add_database failed, error code:" << res << endl;getchar();exit(1);}else{cout << "ebase2_add_database sucess!!" << endl;}/* 关闭连接 */ebase2_close(&ebase);return 0;}
三、删除数据库
// ProcessDB_API_TEST.cpp : ProcessDB数据库示例
//#include <iostream>
#include <string>
#include <stdio.h>
#include <time.h>
#include <conio.h>
#include "processdb_v2.h"
using namespace std;int main(int argc, char* argv[])
{int res = 0;EBASE ebase = { 0 };/* 初始化连接控制块 */res = ebase2_init(&ebase);if (0 != res){cout << "ebase2_init failed !" << endl;getchar();exit(1);}/*设置超时时间*/int timeout = 30;ebase2_set_options(&ebase, EBASE_CONNECTION_TIMEOUT, &timeout);/* 建立连接 */res = ebase2_connect(&ebase, "127.0.0.1", 8301, "root", "root");if (0 != res){cout << "login failed, \n";getchar();exit(1);}/* 修改数据库 */res = ebase2_delete_database(&ebase, "D99");if (res != 0){cout << "ebase2_delete_database failed, error code:" << res << endl;getchar();exit(1);}else{cout << "ebase2_delete_database sucess!!" << endl;}/* 关闭连接 */ebase2_close(&ebase);return 0;}
四、修改数据库
// ProcessDB_API_TEST.cpp : ProcessDB数据库示例
//#include <iostream>
#include <string>
#include <stdio.h>
#include <time.h>
#include <conio.h>
#include "processdb_v2.h"
using namespace std;int main(int argc, char* argv[])
{int res = 0;EBASE ebase = { 0 };/* 初始化连接控制块 */res = ebase2_init(&ebase);if (0 != res){cout << "ebase2_init failed !" << endl;getchar();exit(1);}/*设置超时时间*/int timeout = 30;ebase2_set_options(&ebase, EBASE_CONNECTION_TIMEOUT, &timeout);/* 建立连接 */res = ebase2_connect(&ebase, "127.0.0.1", 8301, "root", "root");if (0 != res){cout << "login failed, \n";getchar();exit(1);}/* 修改数据库 */res = ebase2_modify_database(&ebase, "D99", "Description007");if (res != 0){cout << "ebase2_modify_database failed, error code:" << res << endl;getchar();exit(1);}else{cout << "ebase2_modify_database sucess!!" << endl;}/* 关闭连接 */ebase2_close(&ebase);return 0;}
五、查询数据库
// ProcessDB_API_TEST.cpp : ProcessDB数据库示例
//#include <iostream>
#include <string>
#include <stdio.h>
#include <time.h>
#include <conio.h>
#include "processdb_v2.h"
using namespace std;int main(int argc, char* argv[])
{EBASE_RES result = NULL;int res = 0;char* desc = NULL;EBASE ebase = { 0 };/* 初始化连接控制块 */res = ebase2_init(&ebase);if (0 != res){cout << "ebase2_init failed !" << endl;getchar();exit(1);}/*设置超时时间*/int timeout = 30;ebase2_set_options(&ebase, EBASE_CONNECTION_TIMEOUT, &timeout);/* 建立连接 */res = ebase2_connect(&ebase, "127.0.0.1", 8301, "root", "root");if (0 != res){cout << "login failed, \n";getchar();exit(1);}/* 根据库名查询数据库 */res = ebase2_query_database(&ebase, "D20", &result);if (res != 0){cout << "ebase2_query_database failed, error code:" << res << endl;getchar();exit(1);}else{//数据库查询成功cout << "ebase2_query_database sucess!!" << endl;//查询数据库描述char* desc = NULL;ebase2_get_database_desc(result,0, &desc);cout << "database desc:"<< desc <<endl;OBJECT_ID id ;ebase2_get_database_id(result, 0, &id);cout << "database id:" << id<<endl;char* name = NULL;ebase2_get_database_name(result,0,&name);cout << "database name:" << name <<endl;}/* 关闭连接 */ebase2_close(&ebase);return 0;}
运行示例如下:
ebase2_query_database sucess!!
database desc:ccc
database id:1004
database name:D20
ProcessDB实时/时序数据库——C/C++操作数据库对象相关推荐
- ProcessDB实时/时序数据库——JAVA使用ODBC连接数据库
目录 前言 一.安装ProcessDB-ODBC驱动 1.下载ProcessDB-ODBC驱动 2.安装ProcessDB-ODBC驱动 二.配置ProcessDB数据源 三.JAVA连接Proces ...
- ProcessDB实时/时序数据库——C/C++连接数据库
目录 前言 一.项目准备 1.新建项目 2.添加头文件 3.测试文件模板 二.连接数据库 1.初始化连接控制块 2. 建立连接 3. 关闭连接 三.示例展示 前言 ProcessDB实时/时序数据库支 ...
- ProcessDB实时/时序数据库——C/C++数据订阅功能
目录 前言 一.添加订阅 二.查询订阅数据 三.移除订阅 四.订阅演示 前言 ProcessDB实时/时序数据库在使用C/C++进行开发时,支持订阅的功能来进行数据操作 一.添加订阅 我们使用订阅功能 ...
- oracle表的历史数据转储过程,C#连接Oracle数据库通过存储过程操作数据库 - cuizm的专栏 - CSDN博客...
C#连接Oracle数据库通过存储过程操作数据库 收藏 此文于2011-06-07被推荐到CSDN首页 此文于2011-06-08被推荐到CSDN首页 如何被推荐? 之前笔者一直用C#连接SQL Se ...
- 第二百七十九节,MySQL数据库-pymysql模块操作数据库
MySQL数据库-pymysql模块操作数据库 pymysql模块是python操作数据库的一个模块 connect()创建数据库链接,参数是连接数据库需要的连接参数 使用方式: 模块名称.conne ...
- Java数据库开发与应用之MySQL数据库、JDBC操作数据库、C3P0数据库连接池,Java反射等
MySQL数据库,JDBC接口,MyBatis框架等,掌握的数据的存放和管理. Java数据库开发基础,介绍MySQL数据库.JDBC操作数据库.C3P0数据库连接池,Java反射等内容,进行油画商城 ...
- ProcessDB实时/时序数据库——C/C++查询历史时序数据
目录 前言 一.历史时序数据字段介绍 二.查询历史时序数据 前言 前文已经介绍C/C++使用ProcessDB的基本操作,本文将针对历史时序数据的相关操作进行介绍 一.历史时序数据字段介绍 字段 注释 ...
- django_4:数据库1——django操作数据库
创建数据库记录(插入) 使用python3 manage.py shell(python3亲测好使) ipython3 manage.py shell(亲测不好使) 方式一. [root@centos ...
- python创建数据库表_Python 操作数据库(1)SQL基础
一.数据库 关系型数据库 常见的关系型数据库:SQL Server.MySql.MariaDB.SQLite.ORACLE.PostgreSQL等 非关系型数据库 常见的非关系型数据看:MongoDB ...
最新文章
- solrcloud replica collection core shard slice 概念讲解
- Node Sass does not yet support your current environment
- es7 bulk api 批量插入es
- android过滤数字,android – GPS卫星数量和位置过滤
- Nginx 系列:Nginx 实践,location 路径匹配
- concurrent 底层_JDK1.8 util-concurrent-ConcurrentLinkedQueue源码分析
- 如何在python中安装包_如何给python安装包
- 照片一寸改成二寸,并压缩体积KB的工具
- anaconda3怎么卸载干净,卸载anaconda3的方法是什么
- 智能车的转弯部分_教训:渣土车“两米生死线”千万别跨!记者带你亲身体验...
- 前端度分秒与经纬度互转
- Alpha 冲刺(1/10)
- 数据可视化之使用Matplotlib绘制甘特图
- 记录一下,为什么QQ复制整个文件夹后,仍然没有聊天记录
- 410款INTEL CPU详细技术资料速查表
- Ubuntu16.04通过docker安装微信和QQ
- Vue-GoogleMap (一)实时定位
- linux oracle vncserver,Linux配置vnc
- 线激光扫描三维重建 平移装置 光平面标定
- Fedora14安装VMware tools