ebookingservices / mysql-lited Goto Github PK
View Code? Open in Web Editor NEWLightweight native mysql driver written in D
License: MIT License
Lightweight native mysql driver written in D
License: MIT License
After upgrade from 0.3.15 to 0.3.16 I got an error:
../../.dub/packages/mysql-lited-0.3.16/mysql-lited/src/mysql/inserter.d(210,9): Error: no property 'execute' for type 'Connection!(VibeSocket, cast(ConnectionOptions)0)**'
source/vcm/sqlWrapper.d(59,31): Error: template instance mysql.inserter.inserter!(Connection!(VibeSocket, cast(ConnectionOptions)0)*, string[]) error instantiating
source/updater/action/addRecords.d(22,12): instantiated from here: insert!(int, string)
...
It was o.k. in 0.3.15
This is needed to be used as key for caching a query results or even diagnosis.
Transactions guarantee that all info required are insert without failure before saving records. Especially for things like double entry and payments.
I run MySQL in docker using:
sudo docker create --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=mysecretpassword mysql
And I try to connect to it using:
import mysql.client;
import mysql.socket;
shared static this()
{
auto conn = new Connection!VibeSocket();
conn.connect("host=127.0.0.1;user=root;pwd=mysecretpassword");
conn.execute("SELECT 1 + 1 as solution", (MySQLRow row)
{
return false;
});
}
Giving me an Access violation and the program crashes.
Using vibe-d:0.8.4:
../.dub/packages/mysql-lited-0.4.5/mysql-lited/src/mysql/client.d(11,18): Deprecation: constructor vibe.core.connectionpool.ConnectionPool!(Connection!(VibeSocket, cast(ConnectionOptions)0)*).ConnectionPool.this is deprecated - Use an @safe callback instead
../.dub/packages/mysql-lited-0.4.5/mysql-lited/src/mysql/client.d(19,18): Deprecation: constructor vibe.core.connectionpool.ConnectionPool!(Connection!(VibeSocket, cast(ConnectionOptions)0)*).ConnectionPool.this is deprecated - Use an @safe callback instead
../.dub/packages/mysql-lited-0.4.5/mysql-lited/src/mysql/client.d(27,18): Deprecation: constructor vibe.core.connectionpool.ConnectionPool!(Connection!(VibeSocket, cast(ConnectionOptions)0)*).ConnectionPool.this is deprecated - Use an @safe callback instead
When I run the following code:
auto client = new MySQLClient(...);
auto con = clieck.lockConnection();
con.use(my_db);
auto insert = inserter(con, OnDuplicate.Ignore, "users", "googleID");
foreach(i; 30 .. 40) {
insert.row(i);
}
insert.flush;
0x0059A99B in _d_assert
0x0048E071 in void mysql.packet.InputPacket.skip(uint) at dub\packages\mysql-lited-0.3.15\mysql-lited\src\mysql\packet.d(54)
0x00477FD9 in D5mysql10connection84__T10ConnectionTS5mysql6socket10VibeSocketVE5mysql10connection17ConnectionA0698ACEAD000617DF0366730C40E1B2 at dub\packages\mysql-lited-0.3.15\mysql-lited\src\mysql\connection.d(691)
The table looks like this:
create table users ( id int auto_increment,
googleID bigint unsigned unique,
primary key(id))
When I use OnDuplicate.Error everything works fine. (unless i have duplicates ofc)
Am I using the inserter wrong or is there something else that is problematic?
mysql-lited-0.3.13,compile error
conn.execute("insert into users (name, email) values (?, ?)", "frank", "[email protected]");
connection.d(246,4): Error: undefined identifier 'func'
connection.d(246,4): Error: undefined identifier 'file', did you mean variabl
e 'File'?
connection.d(246,4): Error: undefined identifier 'line', did you mean variabl
e 'Line'?
source\app.d(9,14): Error: template instance mysql.connection.Connection!(VibeSo
cket, cast(ConnectionOptions)0).Connection.execute!("source\app.d", 9, string,
string) error instantiating
dmd failed with exit code 1.
Server version: 10.0.29-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04
usage:
class SqlWrapper
{
enum Options = ConnectionOptions.Default;
alias ClientType = MySQLClientT!(VibeSocket,Options);
private
{
static __gshared Mutex mutex;
ClientType client;
Connection!(VibeSocket, Options)* conn;
}
this(string connectionString)
{
client = new ClientType(connectionString);
conn = client.lockConnection();
}
....
}
Error:
core.exception.AssertError@../../.dub/packages/mysql-lited-0.3.15/mysql-lited/src/mysql/packet.d(24): Assertion failure
----------------
??:? _d_assert [0x81834c]
??:? void mysql.packet.__assert(int) [0x770b3d]
../../.dub/packages/mysql-lited-0.3.15/mysql-lited/src/mysql/packet.d:24 pure nothrow @nogc ushort mysql.packet.InputPacket.eat!(ushort).eat() [0x7562a3]
../../.dub/packages/mysql-lited-0.3.15/mysql-lited/src/mysql/connection.d:717 void mysql.connection.__T10ConnectionTS5mysql6socket10VibeSocketVE5mysql10connection17ConnectionOptionsi0Z.Connection.eatStatus!("../../.dub/packages/mysql-lited-0.3.15/mysql-lited/src/mysql/connection.d", 671uL).eatStatus(mysql.packet.InputPacket, bool) [0x75b42f]
../../.dub/packages/mysql-lited-0.3.15/mysql-lited/src/mysql/connection.d:671 void mysql.connection.__T10ConnectionTS5mysql6socket10VibeSocketVE5mysql10connection17ConnectionOptionsi0Z.Connection.eatHandshake(mysql.packet.InputPacket) [0x7509e3]
../../.dub/packages/mysql-lited-0.3.15/mysql-lited/src/mysql/connection.d:492 void mysql.connection.__T10ConnectionTS5mysql6socket10VibeSocketVE5mysql10connection17ConnectionOptionsi0Z.Connection.connect() [0x74ff97]
../../.dub/packages/mysql-lited-0.3.15/mysql-lited/src/mysql/connection.d:144 void mysql.connection.__T10ConnectionTS5mysql6socket10VibeSocketVE5mysql10connection17ConnectionOptionsi0Z.Connection.connect(immutable(char)[]) [0x74f72b]
../../.dub/packages/mysql-lited-0.3.15/mysql-lited/src/mysql/client.d:13 _D5mysql6client86__T12MySQLClientTTS5mysql6socket10VibeSocketVE5mysql10connection17ConnectionOptionsi0Z12MySQLClientT6__ctorMFAyaZ9__lambda2MFZPS5mysql10connection84__T10ConnectionTS5mysql6socket10VibeSocketVE5mysql10connection17ConnectionOptionsi0Z10Connection [0x74eff2]
../../.dub/packages/vibe-d-0.7.30/vibe-d/source/vibe/core/connectionpool.d:87 vibe.core.connectionpool.LockedConnection!(mysql.connection.__T10ConnectionTS5mysql6socket10VibeSocketVE5mysql10connection17ConnectionOptionsi0Z.Connection*).LockedConnection vibe.core.connectionpool.ConnectionPool!(mysql.connection.__T10ConnectionTS5mysql6socket10VibeSocketVE5mysql10connection17ConnectionOptionsi0Z.Connection*).ConnectionPool.lockConnection() [0x751f9d]
../../.dub/packages/mysql-lited-0.3.15/mysql-lited/src/mysql/client.d:35 vibe.core.connectionpool.LockedConnection!(mysql.connection.__T10ConnectionTS5mysql6socket10VibeSocketVE5mysql10connection17ConnectionOptionsi0Z.Connection*).LockedConnection mysql.client.__T12MySQLClientTTS5mysql6socket10VibeSocketVE5mysql10connection17ConnectionOptionsi0Z.MySQLClientT.lockConnection() [0x74f43b]
src/vcm/sqlWrapper.d:21 vcm.sqlWrapper.SqlWrapper vcm.sqlWrapper.SqlWrapper.__ctor(immutable(char)[]) [0x74498b]
...
Hi there, this isn't a bug but just wondering if you can advise what Type I can use to store the MySQL connection as a private class attribute.
e.g.
class DB {
private Connection conn;
this {
this.conn = client.lockConnection();
}
}
Can you provide an example of what to use for "Connection" as the type?
Cheers and thanks!
when i run this simple code in the unittest mode,the app will cause a memory exception after exiting
shared static this()
{
import mysql;
auto client = new MySQLClient("host=127.0.0.1;user=root;pwd=test;db=motion");
}
core.exception.InvalidMemoryOperationError@src\core\exception.d(679): Invalid memory operation
I have a struct
struct Foo {
int[10] bar;
}
that I wanted to deserialize but that is not supported.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.