1 module mysqln; 2 3 import mysql; 4 import std.stdio; 5 6 void main(string [] args) 7 { 8 immutable uint myFlags = SvrCapFlags.SECURE_PWD | SvrCapFlags.ALL_COLUMN_FLAGS | SvrCapFlags.PROTOCOL41 | SvrCapFlags.SECURE_CONNECTION | SvrCapFlags.WITH_DB; // | SvrCapFlags.MULTI_STATEMENTS | SvrCapFlags.MULTI_RESULTS; 9 10 auto c = new Connection("host", "user", "password", "database"); 11 scope(exit) c.close(); 12 // writefln("You have connected to server version %s", c.serverVersion); 13 // writefln("With currents stats : %s", c.serverStats()); 14 auto caps = c.serverCapabilities; 15 writefln("MySQL Server %s with capabilities (%b):", c.serverVersion, caps); 16 if(caps && SvrCapFlags.SECURE_PWD) 17 writeln("\tLong passwords"); 18 if(caps && SvrCapFlags.FOUND_NOT_AFFECTED) 19 writeln("\tReport rows found rather than rows affected"); 20 if(caps && SvrCapFlags.ALL_COLUMN_FLAGS) 21 writeln("\tSend all column flags"); 22 if(caps && SvrCapFlags.WITH_DB) 23 writeln("\tCan take database as part of login"); 24 if(caps && SvrCapFlags.NO_SCHEMA) 25 writeln("\tCan disallow database name as part of column name database.table.column"); 26 if(caps && SvrCapFlags.CAN_COMPRESS) 27 writeln("\tCan compress packets"); 28 if(caps && SvrCapFlags.ODBC) 29 writeln("\tCan handle ODBC"); 30 if(caps && SvrCapFlags.LOCAL_FILES) 31 writeln("\tCan use LOAD DATA LOCAL"); 32 if(caps && SvrCapFlags.IGNORE_SPACE) 33 writeln("\tCan ignore spaces before '('"); 34 if(caps && SvrCapFlags.PROTOCOL41) 35 writeln("\tCan use 4.1+ protocol"); 36 if(caps && SvrCapFlags.INTERACTIVE) 37 writeln("\tInteractive client?"); 38 if(caps && SvrCapFlags.SSL) 39 writeln("\tCan switch to SSL after handshake"); 40 if(caps && SvrCapFlags.IGNORE_SIGPIPE) 41 writeln("\tIgnore sigpipes?"); 42 if(caps && SvrCapFlags.TRANSACTIONS) 43 writeln("\tTransaction Support"); 44 if(caps && SvrCapFlags.SECURE_CONNECTION) 45 writeln("\t4.1+ authentication"); 46 if(caps && SvrCapFlags.MULTI_STATEMENTS) 47 writeln("\tMultiple statement support"); 48 if(caps && SvrCapFlags.MULTI_RESULTS) 49 writeln("\tMultiple result set support"); 50 writeln(); 51 52 MetaData md = MetaData(c); 53 auto dbList = md.databases(); 54 writefln("Found %s databases", dbList.length); 55 foreach (db ; dbList) 56 { 57 c.selectDB(db); 58 auto curTables = md.tables(); 59 writefln("Database '%s' has %s table%s.", db, curTables.length, curTables.length == 1?"":"s"); 60 foreach(tbls ; curTables) 61 { 62 writefln("\t%s", tbls); 63 } 64 } 65 } 66