buggins / ddbc Goto Github PK
View Code? Open in Web Editor NEWDDBC is DB Connector for D language (similar to JDBC)
DDBC is DB Connector for D language (similar to JDBC)
SQLITEDriver setDateTime() and fromDateTime() are based on D toISOString() and fromISOString() which supports YYYYMMDDThhmmss format, but it is not compatible with SQLite3 datetime functions.
SQLite3 supports various formats such as YYYY-MM-DD HH:MM:SS or YYYY-MM-DDTHH:MM:SS. Details are described in thefollowing document:
https://www.sqlite.org/lang_datefunc.html
Hi,
when using the odbc driver with an Oracle database my program crashed with an exception ("Type 3 not supported").
I could fix this by adding a case to the switch statement in line: 922 of file drivers/odbcddbc.d:
case SQL_DECIMAL: return readValue!(char[]);
I'm not experienced with SQL (i want to use ddbc for a sql course at my university) so maybe i miss some subtle issue with this.
It also works to convert it to double like this,
case SQL_DECIMAL: return readValue!double;
but in my case the decimal type is used to store user IDs and converting to a floating point type would make no sense...
Only getDateTime(int) is available.
Hi. I'm having trouble figuring out how to access a prepared statement already on the PostGres server.
My d code is:
auto stmt = conn.createStatement();
scope(exit) stmt.close();
auto rs = stmt.executeQuery(format("SELECT create_step(%d, '%s', %d);", parentId, name, rank));
scope(exit) rs.close();
My stored procedure is:
-- Function: create_step(integer, character varying, integer)
-- DROP FUNCTION create_step(integer, character varying, integer);
CREATE OR REPLACE FUNCTION create_step(new_parent_id integer, new_name character varying, new_rank integer)
RETURNS step AS
$BODY$
DECLARE
created_step step%ROWTYPE;
BEGIN
UPDATE steps SET rank = rank + 1 WHERE parent_id = new_parent_id AND rank >= new_rank;
INSERT INTO steps (parent_id, name, rank)
VALUES (new_parent_id, new_name, new_rank)
RETURNING id, parent_id, name, rank INTO created_step;
RETURN created_step;
END
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION create_step(integer, character varying, integer)
OWNER TO postgres;
And the stack trace is:
ddbc.core.SQLException@../../.dub/packages/ddbc-0.2.24/source/ddbc/drivers/pgsqlddbc.d(401): Unsupported column type 16563
----------------
../../.dub/packages/ddbc-0.2.24/source/ddbc/drivers/pgsqlddbc.d:401 void ddbc.drivers.pgsqlddbc.PGSQLStatement.fillData(ddbc.drivers.pgsql.PGresult*, ref std.variant.VariantN!(32uL).VariantN[][]) [0x72576c]
../../.dub/packages/ddbc-0.2.24/source/ddbc/drivers/pgsqlddbc.d:443 ddbc.core.ResultSet ddbc.drivers.pgsqlddbc.PGSQLStatement.executeQuery(immutable(char)[]) [0x725a6c]
source/storage.d:79 models.Step storage.PostGresStorage.createStep(int, immutable(char)[], int) [0x71ef98]
source/app.d:38 models.Step app.MyAPIImplementation.createStep(int, immutable(char)[], int) [0x6e748e]
source/app.d:44 void app.MyAPIImplementation.__unittestL41_1() [0x6e7539]
I feel like there's some example or documentation I'm missing. I can call a non-parameterized stored procedure with
auto rs = stmt.executeQuery("SELECT create_step_table()");
Does anyone have any idea what causes this? I can't seem to figure it out as libpq.dll is located within the folder of the executable.
I'm on Windows and compiled with dub build -a=x86_mscoff
The screenshot shows the error and dub configurations.
I'm simply trying to compile and run the postgresql example give in the read me.
Am I missing some configurations or setup?
please release a new version
during ODBC testing a created a table with some columns as NVARCHAR but the driver didn't recognise the type so I had to resort to using VARCHAR to get things working.
I am trying set up PG connection. Here is my code:
import std.stdio;
import std.conv;
import std.algorithm;
import std.datetime;
import std.path;
import std.file;
import ddbc.all;
import parseconfig;
import dbconnect;
ParseConfig config;
void main()
{
config = new ParseConfig();
PGSQLDriver driver = new PGSQLDriver();
string url = PGSQLDriver.generateUrl(config.dbhost, to!short(config.dbport), config.dbname);
string[string] params = PGSQLDriver.setUserAndPassword(config.dbuser, config.dbpass);
DataSource ds = new ConnectionPoolDataSourceImpl(driver, url, params);
auto conn = ds.getConnection();
}
Error massage:
ddbc.core.SQLException@C:\Users\bubenkov_di\AppData\Roaming\dub\packages\ddbc-0.
2.24\source\ddbc\drivers\pgsqlddbc.d(468): ╨Ю╨и╨Ш╨С╨Ъ╨Р: ╨╜╨╡╤А╨░╤Б╨┐╨╛╨╖╨╜╨░╨╜
╨╜╤Л╨╣ ╨┐╨░╤А╨░╨╝╨╡╤В╤А ╨║╨╛╨╜╤Д╨╕╨│╤Г╤А╨░╤Ж╨╕╨╕: "autocommit"
----------------
0x0043A4C4 in bool std.exception.enforceEx!(ddbc.core.SQLException).enforceEx!(b
ool).enforceEx(bool, lazy immutable(char)[], immutable(char)[], uint) at C:\D\dm
d2\windows\bin\..\..\src\phobos\std\exception.d(618)
0x00426694 in int ddbc.drivers.pgsqlddbc.PGSQLStatement.executeUpdate(immutable(
char)[], out std.variant.VariantN!(20u).VariantN) at C:\Users\bubenkov_di\AppDat
a\Roaming\dub\packages\ddbc-0.2.24\source\ddbc\drivers\pgsqlddbc.d(468)
0x00426429 in int ddbc.drivers.pgsqlddbc.PGSQLStatement.executeUpdate(immutable(
char)[]) at C:\Users\bubenkov_di\AppData\Roaming\dub\packages\ddbc-0.2.24\source
\ddbc\drivers\pgsqlddbc.d(446)
0x0042398C in void ddbc.drivers.pgsqlddbc.PGSQLConnection.setAutoCommit(bool) at
C:\Users\bubenkov_di\AppData\Roaming\dub\packages\ddbc-0.2.24\source\ddbc\drive
rs\pgsqlddbc.d(267)
0x0042309A in ddbc.drivers.pgsqlddbc.PGSQLConnection ddbc.drivers.pgsqlddbc.PGSQ
LConnection.__ctor(immutable(char)[], immutable(char)[][immutable(char)[]]) at C
:\Users\bubenkov_di\AppData\Roaming\dub\packages\ddbc-0.2.24\source\ddbc\drivers
\pgsqlddbc.d(166)
0x0042246E in ddbc.core.Connection ddbc.drivers.pgsqlddbc.PGSQLDriver.connect(im
mutable(char)[], immutable(char)[][immutable(char)[]]) at C:\Users\bubenkov_di\A
ppData\Roaming\dub\packages\ddbc-0.2.24\source\ddbc\drivers\pgsqlddbc.d(1217)
0x00423F27 in ddbc.core.Connection ddbc.common.DataSourceImpl.getConnection() at
C:\Users\bubenkov_di\AppData\Roaming\dub\packages\ddbc-0.2.24\source\ddbc\commo
n.d(42)
0x0042259B in ddbc.core.Connection ddbc.common.ConnectionPoolDataSourceImpl.getC
onnection() at C:\Users\bubenkov_di\AppData\Roaming\dub\packages\ddbc-0.2.24\sou
rce\ddbc\common.d(116)
0x0040312D in _Dmain at D:\Project\2016\DBSync\source\app.d(29)
0x004CEB0B in D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv
0x004CEACF in void rt.dmain2._d_run_main(int, char**, extern (C) int function(ch
ar[][])*).runAll()
0x004CE9D0 in _d_run_main
0x00421030 in main at D:\Project\2016\DBSync\source\app.d(7)
0x0051B9FD in mainCRTStartup
0x7668338A in BaseThreadInitThunk
0x77A99A02 in RtlInitializeExceptionChain
0x77A999D5 in RtlInitializeExceptionChain
PostgreSQL 9.5.1
the sqlite driver is only dealing with YYYY-MM-DD format for Date.
getDateTime
and setDateTime
only support up to precision in seconds, but msecs and usecs are useful in many situations, and are supported by postegresql's timestamp type.
I can't find any documentation about errors. I'm running queries that I know are wrong and it's not throwing any exception and I can't figure out how to see if it actually succeeded or where to get an error message.
CREATE TABLE "USERS" (
guid uuid,
name text,
"FL" integer,
id bigint NOT NULL
);
INSERT INTO public."USERS"(guid, name, "FL", id)
VALUES ('cd3c7ffd-7919-f6c5-999d-5586d9f3b261', 'vasia', 10, 1);
I need any way to select and insert GUIDs to DB. Is there any way to do it now. Any way? Maybe not best, just to get it work.
auto rs = stmt.executeQuery(`SELECT guid, name, "FL", id FROM public."USERS";`);
while (rs.next())
writeln(to!string(rs.getString(1)) ~ "\t" ~ rs.getString(2) ~ "\t" );
When I query database with enum columns, this exception throws:
ddbc.core.SQLException@/home/sdev/.dub/packages/ddbc-0.3.7/ddbc/source/ddbc/drivers/pgsqlddbc.d(562): Unsupported column type 16451
where 16451 is a custom defined enum type, with something like:
create type status as enum ('received', 'rejected', 'sent', 'accepted');
Can you add support for these enum types?
ddbc.core.SQLException@../../../.dub/packages/ddbc-0.4.1/ddbc/source/ddbc/drivers/sqliteddbc.d(917): Cannot convert string to DateTime - 20190915T151851
----------------
../../../.dub/packages/ddbc-0.4.1/ddbc/source/ddbc/drivers/sqliteddbc.d:917 std.datetime.date.DateTime ddbc.drivers.sqliteddbc.SQLITEResultSet.getDateTime(int) [0xb87f6e]
../../../.dub/packages/hibernated-0.3.5/hibernated/source/hibernated/metadata.d-mixin-3365:3953 void hibernated.metadata.SchemaInfoImpl!(eloquent.model.user.User, eloquent.model.user.UserData, eloquent.model.blogpost.BlogPost, eloquent.model.blogpost.BlogPostData, eloquent.model.comment.Comment, eloquent.model.comment.CommentData).SchemaInfoImpl._sharedStaticCtor_L3365_C1().__funcliteral107(Object, ddbc.core.DataSetReader, int) [0xac184f]
../../../.dub/packages/hibernated-0.3.5/hibernated/source/hibernated/metadata.d:3275 int hibernated.metadata.SchemaInfo.readAllColumns(Object, ddbc.core.DataSetReader, int).__foreachbody4(ref const(hibernated.metadata.PropertyInfo)) [0xb52857]
../../../.dub/packages/hibernated-0.3.5/hibernated/source/hibernated/metadata.d:292 const int hibernated.metadata.EntityInfo.opApply(int delegate(ref const(hibernated.metadata.PropertyInfo))) [0xb50224]
../../../.dub/packages/hibernated-0.3.5/hibernated/source/hibernated/metadata.d:3257 const int hibernated.metadata.SchemaInfo.readAllColumns(Object, ddbc.core.DataSetReader, int) [0xb526ff]
../../../.dub/packages/hibernated-0.3.5/hibernated/source/hibernated/session.d:897 Object hibernated.session.QueryImpl.readRelations(Object, ddbc.core.DataSetReader, hibernated.session.PropertyLoadMap) [0xb5ae03]
../../../.dub/packages/hibernated-0.3.5/hibernated/source/hibernated/session.d:1085 Object[] hibernated.session.QueryImpl.listObjects(Object, hibernated.session.PropertyLoadMap) [0xb5c771]
../../../.dub/packages/hibernated-0.3.5/hibernated/source/hibernated/session.d:1060 Object[] hibernated.session.QueryImpl.listObjects(Object) [0xb5c511]
../../../.dub/packages/hibernated-0.3.5/hibernated/source/hibernated/session.d:973 Object[] hibernated.session.QueryImpl.listObjects() [0xb5b998]
../../../.dub/packages/hibernated-0.3.5/hibernated/source/hibernated/session.d:160 eloquent.model.blogpost.BlogPost[] hibernated.session.Query.list!(eloquent.model.blogpost.BlogPost).list() [0xb0fc82]
While working on #62 I've noticed an issue in ddbc pods.d in which the following struct was resulting in source/ddbc/pods.d-mixin-1062(1062,37): Error: generated function ddbc.ddbctest.main.User.opAssign(User p) is not callable using argument types ()
:
struct User {
long id;
string name;
int flags;
Date dob;
SysTime created;
}
It seems that in some cases the D compiler can sometimes generate an opAssign
, see documentation:
Structs with (possibly nested) postblit operator(s) will have a hidden yet elaborate compiler generated assignment operator (unless explicitly disabled).
In a similar fashion if you decide to use a class instead of a struct you can end up hitting errors if overriding a function such as toString()
:
class User {
long id;
string name;
int flags;
Date dob;
override string toString() {
return format("{id: %s, name: %s, flags: %s, dob: %s}", id, name, flags, dob);
}
}
results in source/ddbc/pods.d(435,9): Error: "Member toString of class User has unsupported type string()"
.
I'll fix this prior to doing the SysTime changes.
If params
isn't passed into the PGSQLConnection
constructor, there's a range violation. Preferably, it should be able to read the user and password from the url.
The topic is there http://stackoverflow.com/questions/36469669/how-to-load-unload-binary-blob-from-postgresql-with-d
http://img.ctrlv.in/img/16/04/07/57063cd3dc645.png
Possible it's DDBC bug.
ddbc 0.2.25 breaks my projects build:
ddbc 0.2.25: building configuration "full"...
../../../.dub/packages/ddbc-0.2.25/source/ddbc/drivers/mysqlddbc.d(40,8): Error: module connection is in file 'mysql/connection.d' which cannot be read
import path[0] = ../../../.dub/packages/ddbc-0.2.25/source/
import path[1] = /usr/include/dmd/phobos
import path[2] = /usr/include/dmd/druntime/import
dmd failed with exit code 1.
I have to set it back to version 0.2.24 in dub.selections.json
I use dmd version 2.071.0 with dub 0.9.24
some changes are needed for source/ddbc/drivers/mysqlddbc.d
to still compile with latest version of mysql-native
mysql-native 1.1.0: building configuration "library"...
ddbc 0.3.2: building configuration "full"...
../../../.dub/packages/ddbc-0.3.2/ddbc/source/ddbc/drivers/mysqlddbc.d(319,15): Error: undefined identifier 'Command'
../../../.dub/packages/ddbc-0.3.2/ddbc/source/ddbc/drivers/mysqlddbc.d(342,23): Error: undefined identifier 'FieldDescription'
../../../.dub/packages/ddbc-0.3.2/ddbc/source/ddbc/drivers/mysqlddbc.d(359,23): Error: undefined identifier 'ParamDescription'
dmd failed with exit code 1.
my app hooks into an existing schema. there are some NON NULL fields in my user table that I don't care about so I just give them an empty string. eg:
User user = new User;
user.username = username;
user.pass = passwdHash;
user.nicename = "";
user.displayname = username;
user.email = email;
user.url = "";
import std.datetime;
SysTime now = Clock.currTime(UTC());
user.registered = cast(DateTime) now;
session.save(user);
this should be fine (and is when using sqlite) but ddbc falls over when I'm using the MySQL driver:
/ddbc-0.2.26/ddbc/source/ddbc/drivers/mysqlddbc.d(528): MySQL error: Column 'user_nicename' cannot be null
SQLITEDriver driver = new SQLITEDriver();
string url = "zzz.db"; // file with DB
How to create empty db and write it's to disk?
If we have to default to something, the current time would be a better option for defaulting to. Really though it would be better to for the value to be null if that's what is in the database.
I am trying to build last version in new project. But It's produce next error:
C:\Users\bubenkov_di\AppData\Roaming\dub\packages\ddbc-0.2.25\ddbc\source\ddbc\drivers\mysqlddbc.d(40,8): Error: module connection is in file 'mysql\connection.d' which cannot be read
import path[0] = C:\Users\bubenkov_di\AppData\Roaming\dub\packages\ddbc-0.2.25\ddbc\sourceimport path[1] = C:\D\dmd2\windows\bin\..\..\src\phobos import path[2] = C:\D\dmd2\windows\bin\..\..\src\druntime\import
ddbc-0.2.24 works fine.
I tried to do dub clean && dub upgrade, but with same result.
hello
how do you set environment to run ddbc ?
i download 'ddbc-master' and copied whole ddbc folder in source into my project folder.
and those 3 files in ddbc\libs\win32 to system32 (and into my project folder just for sure).
and this:
// i use CodeBlocks IDE
module main;
import std.stdio;
import ddbc;
int main(string[] args)
{
writefln("Hello World\n");
return 0;
}
when i press compile, i get this error:
||=== Build: Debug in database (compiler: Digital Mars D Compiler) ===|
|| Symbol Undefined _D4ddbc12__ModuleInfoZ|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
im new to dlang, what did i do wrong?
Performing "debug" build using dmd for x86.
derelict-util 2.1.0: building configuration "library"...
derelict-pq 2.0.2: building configuration "library"...
vibe-d:utils 0.7.30: building configuration "library"...
vibe-d:data 0.7.30: building configuration "library"...
vibe-d:core 0.7.30: building configuration "libevent"...
mysql-native 1.0.0: building configuration "library"...
ddbc 0.3.2: building configuration "full"...
C:\Users\dbubnenkov\AppData\Roaming\dub\packages\ddbc-0.3.2\ddbc\source\ddbc\dri
vers\mysqlddbc.d(319,15): Error: undefined identifier 'Command'
C:\Users\dbubnenkov\AppData\Roaming\dub\packages\ddbc-0.3.2\ddbc\source\ddbc\dri
vers\mysqlddbc.d(342,23): Error: undefined identifier 'FieldDescription'
C:\Users\dbubnenkov\AppData\Roaming\dub\packages\ddbc-0.3.2\ddbc\source\ddbc\dri
vers\mysqlddbc.d(359,23): Error: undefined identifier 'ParamDescription'
dmd failed with exit code 1.
for a long time ddbc has had a linker problem on OSX. from the comments on ldc-developers/ldc#2159
I have fixed it on my fork: SingingBush@5eab6cd
will do a pull request.
Does anyone know where to get proper 64 bit version of libpq.dll?
Please upgrade to 0.0.10, because 0.0.9 is not compatible with recent vibe.d
Issue fixed: mysql-d/mysql-native#16
Using dub build --build=release with either ldc2 1.6.0 or dmd 2.078.0 gives the following when trying to use insert from pods.d
/home/user/.dub/packages/ddbc-0.3.7/ddbc/source/ddbc/pods.d(436,9): Error: cannot interpret halt at compile time
/home/user/.dub/packages/ddbc-0.3.7/ddbc/source/ddbc/pods.d(484,35): called from here: getPropertyMemberType()
Making the assert on line 436 static seems to resolve this
I know this is a big ask but it would be great to have. And of course to then support it in hibernated.
using SQLite it should be possible to insert NOW as a datetime value and have the code do:
immutable SysTime now = Clock.currTime();
return DateTime(now.year, now.month, now.day, now.hour, now.minute, now.second);
When using SQLITEDriver in codes like this:
Statement stmt = conn.createStatement();
scope(exit) stmt.close();
ResultSet rs = stmt.executeQuery("SELECT id FROM mytable");
scope(exit) rs.close();
while (rs.next()) {
long id = rs.getLong("id");
}
I get Column id not found
error, though I really have id
column.
This works OK:
long id = rs.getLong(1);
Just when I use column names in string, I get errors.
I can't understand what I am doing wrong. Code example show:
// our POD object
struct User {
long id;
string name;
int flags;
}
writeln("reading all user table rows");
foreach(ref e; stmt.select!User) {
writeln("id:", e.id, " name:", e.name, " flags:", e.flags);
}
this in my case work fine:
auto newimages = db.stmt.executeQuery(sql);
But when I am trying this:
foreach(ref e; db.stmt.select!DBData)
{
}
I am getting error: Error: no property 'select' for type 'ddbc.core.Statement'
. What's wrong?
I get a SegFault with the main method below which uses HibernateD . The second main method which uses ddbc just works fine. I think there is a bug with PreparedStatement class in HibernateD. ddbc fails when I use a PreparedStatement. The code below shows that.
This method uses HibernateD and it fails.
int main() {
// setup DB connection
string url = MySQLDriver.generateUrl("localhost", 3306, "test");
string[string] params = MySQLDriver.setUserAndPassword("test", "test");
DataSource ds = new ConnectionPoolDataSourceImpl(new MySQLDriver(), url, params);
// create metadata from annotations
EntityMetaData schema = new SchemaInfoImpl!(Preferences);
// create session factory
Dialect dialect = new MySQLDialect();
SessionFactory factory = new SessionFactoryImpl(schema, dialect, ds);
scope(exit) factory.close();
auto conn = ds.getConnection();
scope(exit) conn.close();
// create session
Session sess = factory.openSession();
scope(exit) sess.close();
Query q = sess.createQuery("select p from Preferences p");
Preferences[] list = q.list!Preferences();
return 0;
}
The code below uses ddbc. It works.
int main(string[] args) {
string url = "mysql://localhost:3306/test?user=test,password=test";
// creating Connection
auto conn = createConnection(url);
scope(exit) conn.close();
// creating Statement
auto stmt = conn.createStatement();
scope(exit) stmt.close();
// reading DB
auto rs = stmt.executeQuery("SELECT * FROM preferences_wm ORDER BY id");
writeln(rs.getFetchSize());
return 0;
}
The code below uses ddbc and prepared statement. This throws SegFault just like the first piece of code.
int main(string[] args) {
string url = "mysql://localhost:3306/webmarx?user=webmarx_dev,password=webm@rx";
// creating Connection
auto conn = createConnection(url);
scope(exit) conn.close();
// creating Statement
auto stmt = conn.createStatement();
scope(exit) stmt.close();
PreparedStatement prepStatement = conn.prepareStatement("SELECT * FROM preferences_wm ORDER BY id");
scope(exit) prepStatement.close();
ResultSet rs = prepStatement.executeQuery();
writeln(rs.getFetchSize());
return 0;
}
Tests added yesterday revealed that getFetchSize is not always implemented.
It looks like this has been removed:
http://www.postgresql.org/docs/9.5/static/release-9-5.html
"Remove server configuration parameter autocommit, which was already deprecated and non-operational (Tom Lane)"
I took a quick stab at making this configurable but quickly ran amuck and gave in. I have a local copy checked out where I just comment out setAutoCommit(true); to make it work.
having done initial SysTime support in #62, I've found a few potential problems so will make a few improvements and tests
I'm not yet sure of the cause but there seems to be a problem with the mysql driver.
ddbc.core.SQLException@../../../.dub/packages/ddbc-0.3.7/ddbc/source/ddbc/drivers/mysqlddbc.d(543): null this
----------------
../../../.dub/packages/ddbc-0.3.7/ddbc/source/ddbc/drivers/mysqlddbc.d:543 ddbc.core.ResultSet ddbc.drivers.mysqlddbc.MySQLPreparedStatement.executeQuery() [0xd68bb8]
../../../.dub/packages/hibernated-0.3.2/hibernated/source/hibernated/session.d:1068 Object[] hibernated.session.QueryImpl.listObjects(Object, hibernated.session.PropertyLoadMap) [0xd4d541]
../../../.dub/packages/hibernated-0.3.2/hibernated/source/hibernated/session.d:1050 Object[] hibernated.session.QueryImpl.listObjects(Object) [0xd4d3b7]
../../../.dub/packages/hibernated-0.3.2/hibernated/source/hibernated/session.d:964 Object[] hibernated.session.QueryImpl.listObjects() [0xd4c7ee]
../../../.dub/packages/hibernated-0.3.2/hibernated/source/hibernated/session.d:151 eloquent.model.blogpost.BlogPost[] hibernated.session.Query.list!(eloquent.model.blogpost.BlogPost).list() [0xcecc6c]
source/services/blogservice.d:35 eloquent.model.blogpost.BlogPost[] eloquent.services.blogservice.BlogServiceImpl.allBlogPosts() [0xd25f32]
source/controllers/webappcontroller.d:27 void eloquent.controllers.web.WebappController.index() [0xd20fb5]
../../../.dub/packages/vibe-d-0.8.0-rc.6/vibe-d/web/vibe/web/web.d:825 void vibe.web.web.handleRequest!("index", void eloquent.controllers.web.WebappController.index(), eloquent.controllers.web.WebappController).handleRequest(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse, eloquent.controllers.web.WebappController, vibe.web.web.WebInterfaceSettings) [0xd19b6a]
../../../.dub/packages/vibe-d-0.8.0-rc.6/vibe-d/web/vibe/web/web.d:186 @trusted void vibe.web.web.__T20registerWebInterfaceHTC8eloquent11controllers3web16WebappControllerVE4vibe3web6common11MethodStylei5Z.registerWebInterface(vibe.http.router.URLRouter, eloquent.controllers.web.WebappController, vibe.web.web.WebInterfaceSettings).__lambda4(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse) [0xd195b8]
../../../.dub/packages/vibe-d-0.8.0-rc.6/vibe-d/http/vibe/http/router.d:212 _D4vibe4http6router9URLRouter13handleRequestMFNfC4vibe4http6server17HTTPServerRequestC4vibe4http6server18HTTPServerResponseZ21__T9__lambda4TmTAAyaZ9__lambda4MFNfmMAAyaZb [0xdec597]
../../../.dub/packages/vibe-d-0.8.0-rc.6/vibe-d/http/vibe/http/router.d:620 const(@safe bool function(immutable(char)[], scope @safe bool delegate(ulong, scope immutable(char)[][]))) vibe.http.router.MatchTree!(vibe.http.router.Route).MatchTree.doMatch [0xded3be]
../../../.dub/packages/vibe-d-0.8.0-rc.6/vibe-d/http/vibe/http/router.d:553 @safe bool vibe.http.router.MatchTree!(vibe.http.router.Route).MatchTree.match(immutable(char)[], scope @safe bool delegate(ulong, scope immutable(char)[][])) [0xdecbfb]
../../../.dub/packages/vibe-d-0.8.0-rc.6/vibe-d/http/vibe/http/router.d:205 @safe void vibe.http.router.URLRouter.handleRequest(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse) [0xdec24d]
../../../.dub/packages/vibe-d-0.8.0-rc.6/vibe-d/http/vibe/http/server.d:2043 @safe bool vibe.http.server.handleRequest(vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.Stream).InterfaceProxy, vibe.core.net.TCPConnection, vibe.http.server.HTTPListenInfo, ref vibe.http.server.HTTPServerSettings, ref bool, scope std.experimental.allocator.IAllocator) [0xe415aa]
../../../.dub/packages/vibe-d-0.8.0-rc.6/vibe-d/http/vibe/http/server.d:1791 @trusted void vibe.http.server.handleHTTPConnection(vibe.core.net.TCPConnection, vibe.http.server.HTTPListenInfo).__lambda4() [0xe3f905]
../../../.dub/packages/vibe-d-0.8.0-rc.6/vibe-d/http/vibe/http/server.d:1783 @safe void vibe.http.server.handleHTTPConnection(vibe.core.net.TCPConnection, vibe.http.server.HTTPListenInfo) [0xe3f69a]
../../../.dub/packages/vibe-d-0.8.0-rc.6/vibe-d/http/vibe/http/server.d:1657 nothrow @safe void vibe.http.server.listenHTTPPlain(vibe.http.server.HTTPServerSettings, vibe.http.server.HTTPServerContext).doListen(vibe.http.server.HTTPListenInfo, vibe.http.server.HTTPServerContext, bool, bool).__lambda6(vibe.core.net.TCPConnection) [0xe3ee87]
../../../.dub/packages/vibe-core-1.0.0-rc.4/vibe-core/source/vibe/core/task.d:532 _D4vibe4core4task12TaskFuncInfo76__T3setTDFNfS4vibe4core3net13TCPConnectionZvTS4vibe4core3net13TCPConnectionZ3setMFKDFNfS4vibe4core3net13TCPConnectionZvKS4vibe4core3net13TCPConnectionZ12callDelegateFKS4vibe4core4task12TaskFuncInfoZv [0xefc8f2]
../../../.dub/packages/vibe-core-1.0.0-rc.4/vibe-core/source/vibe/core/task.d:557 void vibe.core.task.TaskFuncInfo.call() [0xedef3d]
../../../.dub/packages/vibe-core-1.0.0-rc.4/vibe-core/source/vibe/core/task.d:375 nothrow void vibe.core.task.TaskFiber.run() [0xede390]
??:? void core.thread.Fiber.run() [0xfa3923]
??:? fiber_entryPoint [0xfa3802]
??:? [0xffffffff]
the error occured in this try/catch block:
override ddbc.core.ResultSet executeQuery() {
checkClosed();
lock();
scope(exit) unlock();
try {
Prepared p = prepare(conn.getConnection(), to!string(cmd.sql));
rs = p.querySet();
resultSet = new MySQLResultSet(this, rs, getMetaData());
return resultSet;
} catch (Throwable e) {
throw new SQLException(e);
}
}
In the same was as buggins/hibernated#60 this project should use the following to allow dmd versions above and below 2.089
// For backwards compatibily
// 'enforceEx' will be removed with 2.089
static if(__VERSION__ < 2080) {
alias enforceHelper = enforceEx;
} else {
alias enforceHelper = enforce;
}
With DUB "versions": ["VibeDefaultMain"] and the following code:
shared static this()
{
import ddbc;
string url = "postgresql://localhost:5432/db?user=postgres,password=postgres,ssl=true";
auto conn = createConnection(url);
scope(exit) conn.close();
auto stmt = conn.createStatement();
scope(exit) stmt.close();
}
Appears this error:
ddbc.core.SQLException@../../../../../../../../.dub/packages/ddbc-master/ddbc/source/ddbc/common.d(71): DriverFactory: driver is not found for name "postgresql"
Program exited with code -4
string query_string = (`SELECT user, password FROM otest.myusers where user LIKE ` ~ `'%` ~ request["username"].to!string ~ `%';`);
auto rs = db.stmt.executeQuery(query_string);
string dbpassword;
string dbuser;
while (rs.next())
{
dbuser = rs.getString(1);
dbpassword = rs.getString(2);
writeln(dbuser);
writeln("Place unreachable"); // if SQL result is empty
How I can check if SQL request returned empty result?
/usr/include/dmd/phobos/std/range/primitives.d(174,38): Deprecation: function std.typecons.Nullable!string.Nullable.get_ is deprecated - Implicit conversion with alias Nullable.get this will be removed after 2.096. Please use .get explicitly.
source/ddbc/drivers/mysqlddbc.d(1256,39): Error: cannot implicitly convert expression rs.getFetchSize() of type ulong to int
/usr/bin/dmd failed with exit code 1.
(Dear Vadim )
This is a bug report. The drivers for sqlite and mariadb do not seem to behave consistently in my example program (indeed t the later, do not seem to work at all!)
https://github.com/pdenapo/example_programs_in_D/tree/master/test_ddbc_select
I have created a database with a single table and a single row. I do a simple select statement
SELECT * FROM test WHERE name = 'John';
I want to get only the first result. It seems that the right way of doing that is my method
get_data_with_next()
At least it works with fine the sqlite driver !
(rs.next() seems to be required here, the documentation is not clear enough in my opinion).
However, if I try to run the very same program with the mysql driver (using MariaDb under Debian 10) it fails with an exception.
You can find the output from both cases (and the mariaDB shell in my respository.
this was done in 820afc9 creating issue here for visiblity. As this had minor change to API the next tagged release should be 0.4.0
title says it all. I've changed from an employer that uses MS-SQL to an employer that uses Oracle. I'd really like to get D into the workplace but would need Oracle support in ddbc
mysql-native has now finished with 1.1.* versions and are doing 1.2.* which will not work with ddbc currently.
this isn't an immediate problem because ddbc currently specifies mysql-native as ~>1.1.0
so will pick up v1.1.4 but it's worth keeping up to date with the dependency
when compiling with dub I get:
Building configuration "MySQL", build type debug
Running dmd...
source/ddbc/drivers/mysql.d(1295): Error: template ddbc.drivers.mysql.packInto does not match any function template declaration. Candidates are:
source/ddbc/drivers/mysql.d(1233): ddbc.drivers.mysql.packInto(T, bool IsInt24 = false)(T value, ref ubyte[] array)
source/ddbc/drivers/mysql.d(1295): Error: template ddbc.drivers.mysql.packInto(T, bool IsInt24 = false)(T value, ref ubyte[] array) cannot deduce template function from argument types !()(ushort, ubyte[])
Strange thing is dmd doesn't do this if I do:
dmd -c ./drivers/sha1.d ./drivers/pgsqlddbc.d ./drivers/utils.d ./drivers/mysqlddbc.d ./drivers/sqliteddbc.d ./drivers/mysql.d ./drivers/pgsql.d ./core.d ./common.d
Okay so thats just because USE_MYSQL was missing:
dmd -version=USE_MYSQL ./drivers/sha1.d ./drivers/pgsqlddbc.d ./drivers/utils.d ./drivers/mysqlddbc.d ./drivers/sqliteddbc.d ./drivers/mysql.d ./drivers/pgsql.d ./core.d ./common.d -c
shows the problem.
One more thing. The exact same lines of code exist in mysql-native and they compile fine.
in the title
EDIT: not sure. Will maybe reopen
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.