当前位置: 首页 > 软件库 > 数据库相关 > >

crystal-mysql

MySQL connector for Crystal
授权协议 MIT License
开发语言 C/C++
所属分类 数据库相关
软件类型 开源软件
地区 不详
投 递 者 苏鸿羽
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

crystal-mysql

MySQL driver implement natively in Crystal, without relying on external libraries.

Check crystal-db for general db driver documentation. crystal-mysql driver is registered under mysql:// uri.

Why

Using a natively implemented library has a significant performance improvement over working with an external library, since there is no need to copy data to and from the Crystal space and the native code. Initial tests with the library have shown a 2x-3x performance boost, though additional testing is required.

Also, going through the MySQL external library blocks the Crystal thread using it, thus imposing a significant penalty to concurrent database accesses, such as those in web servers. We aim to overcome this issue through a full Crystal implementation of the MySQL driver that plays nice with non-blocking IO.

Status

This driver is a work in progress.It implements mysql's binary protocol to create prepared statements.Contributions are most welcome.

Installation

Add this to your application's shard.yml:

dependencies:
  mysql:
    github: crystal-lang/crystal-mysql

Usage

require "mysql"

# connect to localhost mysql test db
DB.open "mysql://root@localhost/test" do |db|
  db.exec "drop table if exists contacts"
  db.exec "create table contacts (name varchar(30), age int)"
  db.exec "insert into contacts values (?, ?)", "John Doe", 30

  args = [] of DB::Any
  args << "Sarah"
  args << 33
  db.exec "insert into contacts values (?, ?)", args: args

  puts "max age:"
  puts db.scalar "select max(age) from contacts" # => 33

  puts "contacts:"
  db.query "select name, age from contacts order by age desc" do |rs|
    puts "#{rs.column_name(0)} (#{rs.column_name(1)})"
    # => name (age)
    rs.each do
      puts "#{rs.read(String)} (#{rs.read(Int32)})"
      # => Sarah (33)
      # => John Doe (30)
    end
  end
end

When running this example, if you get the following exception:

Unhandled exception: Client does not support authentication protocol requested by server; consider upgrading MySQL client (Exception)

You have two options, set a password for root, or (most recommended option) create another user with access to test database.

CREATE USER 'test'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword';
GRANT ALL PRIVILEGES ON test.* TO 'test'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
quit

Then use the example above changing the DB.open line to

DB.open "mysql://test:yourpassword@localhost/test" do |db|
  • 在应用$mysqli时,因没常用到数据回滚,老忘,整理下,做个记录。 $mysqli->autocommit(FALSE);//自动提交设置关闭 $mysqli->query("BEGIN"); //事务开始,接着下面的执行才可以我们自己控制 try{ $mysqli->query($sql); $q1 = $mysqli->affected_rows; if($q == 1){         

  • Tag Name Description reportlocation When creating a report source using the Java Reporting Component, the report's path can be specified by using either a relative or absolute path. When using relativ

  • 1、安装MySQL 下载MySQL安装包,并上传到Linux服务器上 mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz 解压 [root@localhost tmp]# tar -xzvf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz -C /usr/local/ 修改目录 [root@localhost ~]# m

  • 1. python mysql查不到最新数据 Python创建pymysql连接时,设置 autocommit=True ,即让其操作后自动提交事务。 参考博客: 解决pymysql查不到最新数据的办法 - wintest - 博客园 2. mysql添加列,修改列,删除列 添加列:alter table 表名 add column 列名 varchar(30); 删除列:alter table

  • MS SQL Server捆绑了许多工具——如果您拿走了这些工具,那么在系统之间进行选择将是一件轻而易举的事情。在您的案例中,这些工具似乎提供了有用的功能——所以关键问题是这些工具是否在其他地方可用——以及添加这些工具的成本是否会高于购买MSSQL。 社区版本的od mysql仍然是免费的,而且 MariaDB 和 Drizzle (MySQL的免费分支)更不用说InfoBrights了 colu

  •             OdbcConnection conn;               string connStr = "DRIVER={MySQL ODBC 3.51 Driver};" +                             "SERVER=localhost;" +                             "DATABASE=report;" +

  • 通过JDBC连接MySQL 基本步骤 代码讲解步骤 可能遇到的Bug 基本步骤 JDBC访问MySQL 1.加载JDBC驱动器—>哪个project需要,就添加到该project的jdbc文件夹下, 我的jar包路径是E:\Mysql\mysql-connector-java-5.1.39-bin.jar 2.加载JDBC驱动"driver",注册到DriverManager中—>一般使用反射Cl

  • c#如何动态显示水晶报表? 首先使用CrystalDecisions.CrystalReports.Engine例如,要访问crystal report中的TextObject,必须首先实例化crystal report对象。现在假设crystal report的一个文本对象的名称是text1,内容是“Zhang San”。现在我们需要在代码中动态地将其更改为“Li-Si”,如下所示:crysta

  • MySql的两种引擎分辨是MyISAM和InnoDB,在MySql5.1版本之前的默认引擎是MyISAM,而之后的版本默认引擎就是InnoDB。 MyISAM 和InnoDB 讲解   InnoDB和MyISAM是许多人在使用MySQL时最常用的两个表类型,这两个表类型各有优劣,视具体应用而定。基本的差别为:MyISAM类型不支持事务处理等高级处理,而InnoDB类型支持。MyISAM类型的表强调

  • 当前位置:我的异常网» C# » C#winfrom程序打包发布时安装mysql数据如何做呢 C#winfrom程序打包发布时安装mysql数据如何做呢(2) www.myexceptions.net  网友分享于:2015-08-26  浏览:413次 (KeyCode MSM 处理 Crystal Decisions 密钥号码的安装,注意是添加合并模块,否则没有“MergeMoudulePro

 相关资料
  • Crystal Reports(水晶报表)是一款商务智能(BI)软件,主要用于设计及产生报表。水晶报表是业内最专业、功能最强的报表系统,它除了强大的报表功能外,最大的优势是实现了与绝大多数流行开发工具的集成和接口。在VS.Net平台做过报表开发的程序员,一定都对水晶报表强大、高效、集成等特性留下了深刻印象。 除了开发新程序外,在工作中我们常需要接触到很多较早的软件系统报表功能升级的需求,如果能结合

  • crystal-pg A native, non-blocking Postgres driver for Crystal usage This driver now uses the crystal-db project. Documentation on connecting,querying, etc, can be found at: https://crystal-lang.org/do

  • Redis Client for Crystal A Redis client for the Crystal programming language. Features Performance (> 680,000 commands per second using pipeline on a MacBook Air with a single client thread) Pipelinin

  • crystal-nodejs Node.js engine for crystal-lang. JS code and npm module executes on crystal-nodejs, And don't need to install Node.js binary.Explain about architecture, Compiled as a shared object Node

  • Crystal Website Powered by Jekyll Development setup (via docker) Checkout the repository Run $ docker-compose up Open a browser in localhost:4000 The docker container will launch jekyll with --increme

  • crystal-fann Crystal bindings for the FANN C lib Installation Add this to your application's shard.yml: dependencies: crystal-fann: github: NeuraLegion/crystal-fann Usage Look at the spec for most