GithubHelp home page GithubHelp logo

abscissa / mysql-native-experimental Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 0.0 867 KB

OUTDATED: Use the official mysql-native: https://github.com/mysql-d/mysql-native

Shell 0.59% Batchfile 0.33% Makefile 1.29% D 97.80%

mysql-native-experimental's People

Contributors

abscissa avatar brad-anderson avatar britseye avatar fearfullymade avatar geod24 avatar jollieroger avatar machindertech avatar marenz avatar martinnowak avatar mathias-baumann-sociomantic avatar s-ludwig avatar schancel avatar simendsjo avatar sshamov avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mysql-native-experimental's Issues

How to use isNull?

Sorry, that I probably ask obviously questions, but I can't understand how to use isNull

There is also isNull http://semitwist.com/mysql-native-docs/v0.2.0-preview1/mysql/result/Row.html

Uploading Безымянный.png…

Yeah, it's seems that I understand what do:
Row row = result.front;
when we do SQL request with query it code above take only first element, but when we are doing:
Row row = prepared.queryRow();
it's return only one. And we do not do front. Am I right?

But I still can't get .isNull to work in both cases.

get array of rows

What is the best practice to get from DB array of rows? Only foreach loop? Like:

Row rows = result.front;
foreach(row; rows)
x = row[0]
y = row[1]
....

Or is there any better (native way)?

upd: I tried, but get next error:
default

Examples of getting single entry show:
Row row = result.front;
what result.front; is means here?

P.S. Big thanks for you driver!

lockConnection and createConnection

What is the difference between next 2 functions:

		/// Obtain a connection. If one isn't available, a new one will be created.
		auto lockConnection() { return m_pool.lockConnection(); }

		private Connection createConnection()
		{
			return new Connection(m_host, m_user, m_password, m_database, m_port, m_capFlags);
		}

Why we should create connection in pool:
this.connection = mydb.lockConnection();

instead of:
this.connection = mydb.createConnection();

is there any way to print SQL query?

I want to print query body (possible in Exception text) or maybe after setting prepared args for test purposes.

By code look in next way:

try
{    
PerformerStruct performerStruct;
 Prepared prepared = prepare(database.connection, `SELECT id, login, password, sex, age, city from performers WHERE id=?`);

I know that I can create text variable with SELECT id, login, password, sex, age, city from performers WHERE id=? on top of try and than do:

string myVariableWithSQLQuery = "SELECT id, login, password, sex, age, city from performers WHERE id=?"
try{
...
 Prepared prepared = prepare(database.connection, myVariableWithSQLQuery);

But it's look ugly. Can I print already prepared query like:
writeln(prepared.SQLContent);

?

Variant: attempting to use incompatible types immutable(char)[] and int

As I understood we get data from DB in Variant format. How I can convert it to standard D data types?

I tried:
Row row = result.front;
user.id = row[1].get!int;

and got error: Variant: attempting to use incompatible types immutable(char)[] and int

I found way:
user.id = row[1].convertsTo!(int);
But can't understand if I used it's as intended?

Row schema support

It can be very covenient to have schema for binding to row fetched from DB like:

// structured row annotations
	struct PlaceFull {
		uint id;
		string name;
		@optional string thumbnail;	// ok to be null or missing
		@optional GeoRef location;	// nested fields ok to be null or missing
		@optional @as("contact_person") string contact; // optional, and sourced from field contact_person instead

		@ignore File tumbnail;	// completely ignored
	}

And used as:

// after fetchning
auto place = row.toStruct!PlaceFull;

furthure

// automated struct member uncamelcase
	@uncamel struct PlaceOwner {
		uint placeID;			// matches placeID and place_id
		uint locationId;		// matches locationId and location_id
		string ownerFirstName;	// matches ownerFirstName and owner_first_name
		string ownerLastName;	// matches ownerLastName and owner_last_name
		string feedURL;			// matches feedURL and feed_url
	}

prepared query and queryRow

I am trying to do next:

		Prepared prepared = prepare(connection, `SELECT id, login, password, group from 'users' WHERE login=?`);
		prepared.setArgs(login);
		ResultRange result = prepared.queryRow();

But I am getting error message that ResultRange is not callable with queryRow constructor. Only acceptable is query

What PreparedImpl is different from simple Prepared? I tried it, but got message that it's can't be called because annotate as disabled

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.