RE: Perl DBI or C++ API Help!
Q&D answer in PERL! my ($file); $file = 'database_names'; $cmd = qq!show databases;!; open O, ">cmd" or die "could open cmd - $!"; print O "$cmd\n"; close O; system ("mysql -uusername -ppassword < cmd > $file") == 0 or die "could not do system - $!"; open I, "<$file" or die "could not open $file - $!"; while (){ print "$_"; } close I; -Original Message- From: Bernd Prager [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 03, 2002 2:33 PM To: Sarah Killcoyne; [EMAIL PROTECTED] Subject: Re: Perl DBI or C++ API Help! - Original Message - From: "Sarah Killcoyne" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, December 03, 2002 11:14 AM > I need to be able to connect to mysql through a perl or C++ script without > knowing the name of the database to connect to. ,,, I'm not an expert om the C++ API. But if the host is a UNIX system you can do a RSH command in C++ as well as in Perl. "mysql -u username 'show databases;'" Maybe there's a better solution, but in worst case this would do it. - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: Perl DBI or C++ API Help!
Sarah Killcoyne wrote: I need to be able to connect to mysql through a perl or C++ script without knowing the name of the database to connect to. I can't seem to find a way to do this. Is it possible to either: look up database names so I can pick one before connecting or connect without a database name so I can "show databases;" and pick one then? The reason for this is, this script will be creating the database we need new each time with a different name depending on how the user wants it so it's possible that there are no databases set up at all or a differnt named one each time. My book only shows me how to do it if I know the name. One way could be to connect to the test database and then run the SQL "show databases". - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: Perl DBI or C++ API Help!
- Original Message - From: "Sarah Killcoyne" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, December 03, 2002 11:14 AM > I need to be able to connect to mysql through a perl or C++ script without > knowing the name of the database to connect to. ,,, I'm not an expert om the C++ API. But if the host is a UNIX system you can do a RSH command in C++ as well as in Perl. "mysql -u username 'show databases;'" Maybe there's a better solution, but in worst case this would do it. - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: Perl DBI or C++ API Help!
For Perl... Take a look at the data_sources DBI class method http://search.cpan.org/author/TIMB/DBI-1.32/DBI.pm#DBI_Class_Methods or the ListDBs MetaData Method for DBD::mysql http://search.cpan.org/author/JWIED/DBD-mysql-2.1020/lib/DBD/mysql.pod#Priva te_MetaData_Methods Duncan --- Duncan Salada Titan Systems Corporation 301-925-3222 x375 -Original Message- From: Sarah Killcoyne [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 03, 2002 11:14 AM To: [EMAIL PROTECTED] Subject: Perl DBI or C++ API Help! I need to be able to connect to mysql through a perl or C++ script without knowing the name of the database to connect to. I can't seem to find a way to do this. Is it possible to either: look up database names so I can pick one before connecting or connect without a database name so I can "show databases;" and pick one then? The reason for this is, this script will be creating the database we need new each time with a different name depending on how the user wants it so it's possible that there are no databases set up at all or a differnt named one each time. My book only shows me how to do it if I know the name. Thanks!! Sarah - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Perl DBI or C++ API Help!
I need to be able to connect to mysql through a perl or C++ script without knowing the name of the database to connect to. I can't seem to find a way to do this. Is it possible to either: look up database names so I can pick one before connecting or connect without a database name so I can "show databases;" and pick one then? The reason for this is, this script will be creating the database we need new each time with a different name depending on how the user wants it so it's possible that there are no databases set up at all or a differnt named one each time. My book only shows me how to do it if I know the name. Thanks!! Sarah - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: MySQL++ API Help
David Ayliffe writes: > Does anyone have any SIMPLE proggies written in C++ using the MYSQL++ > API library? Preferably MS Visual Studio 6 format. If so can you please > provide me a link for them or contact me over email directly. > > I'm having problems compiling a project that just connects to the server > issues a query and then exits. I'm getting linker errors all over the > shop (attatched) > > ANY ADVICE FOR C++ DEVELOPMENT USING MYSQL++ API APPRECIATED > > !! Sorry if you get this more than once !! > > Thanks lots > David Ayliffe ([EMAIL PROTECTED]) > Deleting intermediate files and output files for project 'mysqltest - Win32 Debug'. > Configuration: mysqltest - Win32 Debug > Compiling... > mysqltest.cpp > c:\vc\type_info1.hh(39) : warning C4800: 'int' : forcing value to bool 'true' or >'false' (performance warning) > c:\vc\type_info1.hh(159) : warning C4800: 'unsigned int' : forcing value to bool >'true' or 'false' (performance warning) > c:\vc\type_info1.hh(172) : warning C4800: 'int' : forcing value to bool 'true' or >'false' (performance warning) > c:\vc\type_info1.hh(176) : warning C4800: 'int' : forcing value to bool 'true' or >'false' (performance warning) > c:\vc\type_info1.hh(180) : warning C4800: 'int' : forcing value to bool 'true' or >'false' (performance warning) > c:\vc\type_info1.hh(184) : warning C4800: 'int' : forcing value to bool 'true' or >'false' (performance warning) > c:\vc\sql_query1.hh(37) : warning C4800: 'class SQLQuery *' : forcing value to bool >'true' or 'false' (performance warning) > c:\vc\sql_query1.hh(135) : warning C4355: 'this' : used in base member initializer >list > c:\vc\compare1.hh(48) : warning C4800: 'int' : forcing value to bool 'true' or >'false' (performance warning) > c:\vc\result1.hh(33) : warning C4355: 'this' : used in base member initializer list > c:\vc\result1.hh(42) : warning C4800: 'char' : forcing value to bool 'true' or >'false' (performance warning) > Linking... > mysqltest.obj : error LNK2001: unresolved external symbol "public: __thiscall >MysqlConnection::~MysqlConnection(void)" (??1MysqlConnection@@QAE@XZ) > mysqltest.obj : error LNK2001: unresolved external symbol "public: bool __thiscall >MysqlQuery::exec(class std::basic_string,class >std::allocator > const &)" (?exec@MysqlQuery@@QAE_NABV?$basic_string@DU?$char_ > traits@D@std@@V?$allocator@D@2@@std@@@Z) > mysqltest.obj : error LNK2001: unresolved external symbol "public: bool __thiscall >MysqlConnection::real_connect(char const *,char const *,char const *,char const >*,unsigned int,char,unsigned int,char const *)" (?real_connect@MysqlConnection@@QAE_NP > BD000IDI0@Z) > mysqltest.obj : error LNK2001: unresolved external symbol _mysql_init@4 > mysqltest.obj : error LNK2001: unresolved external symbol _mysql_errno@4 > Debug/mysqltest.exe : fatal error LNK1120: 5 unresolved externals > Error executing link.exe. > > mysqltest.exe - 6 error(s), 11 warning(s) > > #include "C:\VC\sqlplus.hh" > #include > #include > > #define MY_DATABASE "telcent" > #define MY_TABLE"nazivi" > #define MY_HOST "localhost" > #define MY_USER "root" > #define MY_PASSWORD "" > #define MY_FIELD"naziv" > #define MY_PORT "3306" > #define MY_QUERY"SELECT URL from my_table as t1, my_table as t2 where t1.field = >t2.field" > > int main (void) > { > Connection con(use_exceptions); > try { > ostrstream strbuf; unsigned int i=0; > con.real_connect >(MY_DATABASE,MY_HOST,MY_USER,MY_PASSWORD,3306,(int)0,60,NULL); > Query query = con.query(); query << MY_QUERY; > //ResUse res = query.use(); Row row; > //strbuf << "delete from " << MY_TABLE << " where " << MY_FIELD << " in >("; > //for UPDATE just replace the above DELETE FROM with UPDATE statement > //for(0;row=res.fetch_row();i++) strbuf << row[0] << ","; if >(!i) return 0; > string output(strbuf.str()); output.erase(output.size()-1,1); output >+= ")"; > query.exec((const string&)output); // cout << output << endl; > return 0; > } catch (BadQuery er) { > cerr << "Error: " << er.error << " " << con.errnum() << endl; > return -1; > } > } Hi! First of all I hope you have used MySQL++ version for VC++. Second, include sqlplus.hh as a last file. Third, you have to add sqlplus lib and mysqlclient lib to your project. Regards, Sinisa __ _ _ ___ == MySQL AB /*/\*\/\*\ /*/ \*\ /*/ \*\ |*| Sinisa Milivojevic /*/ /*/ /*/ \*\_ |*| |*||*| mailto:[EMAIL PROTECTED] /*/ /*/ /*/\*\/*/ \*\|*| |*||*| Larnaca, Cyprus /*/ /*/ /*/\*\_/*/ \*\_/*/ |*| /*/^^^\*\^^^ /*/ \*\Developers Team - Before posting, plea
MySQL++ API Help
Does anyone have any SIMPLE proggies written in C++ using the MYSQL++ API library? Preferably MS Visual Studio 6 format. If so can you please provide me a link for them or contact me over email directly. I'm having problems compiling a project that just connects to the server issues a query and then exits. I'm getting linker errors all over the shop (attatched) ANY ADVICE FOR C++ DEVELOPMENT USING MYSQL++ API APPRECIATED !! Sorry if you get this more than once !! Thanks lots David Ayliffe ([EMAIL PROTECTED]) Deleting intermediate files and output files for project 'mysqltest - Win32 Debug'. Configuration: mysqltest - Win32 Debug Compiling... mysqltest.cpp c:\vc\type_info1.hh(39) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning) c:\vc\type_info1.hh(159) : warning C4800: 'unsigned int' : forcing value to bool 'true' or 'false' (performance warning) c:\vc\type_info1.hh(172) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning) c:\vc\type_info1.hh(176) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning) c:\vc\type_info1.hh(180) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning) c:\vc\type_info1.hh(184) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning) c:\vc\sql_query1.hh(37) : warning C4800: 'class SQLQuery *' : forcing value to bool 'true' or 'false' (performance warning) c:\vc\sql_query1.hh(135) : warning C4355: 'this' : used in base member initializer list c:\vc\compare1.hh(48) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning) c:\vc\result1.hh(33) : warning C4355: 'this' : used in base member initializer list c:\vc\result1.hh(42) : warning C4800: 'char' : forcing value to bool 'true' or 'false' (performance warning) Linking... mysqltest.obj : error LNK2001: unresolved external symbol "public: __thiscall MysqlConnection::~MysqlConnection(void)" (??1MysqlConnection@@QAE@XZ) mysqltest.obj : error LNK2001: unresolved external symbol "public: bool __thiscall MysqlQuery::exec(class std::basic_string,class std::allocator > const &)" (?exec@MysqlQuery@@QAE_NABV?$basic_string@DU?$char_ traits@D@std@@V?$allocator@D@2@@std@@@Z) mysqltest.obj : error LNK2001: unresolved external symbol "public: bool __thiscall MysqlConnection::real_connect(char const *,char const *,char const *,char const *,unsigned int,char,unsigned int,char const *)" (?real_connect@MysqlConnection@@QAE_NP BD000IDI0@Z) mysqltest.obj : error LNK2001: unresolved external symbol _mysql_init@4 mysqltest.obj : error LNK2001: unresolved external symbol _mysql_errno@4 Debug/mysqltest.exe : fatal error LNK1120: 5 unresolved externals Error executing link.exe. mysqltest.exe - 6 error(s), 11 warning(s) #include "C:\VC\sqlplus.hh" #include #include #define MY_DATABASE "telcent" #define MY_TABLE"nazivi" #define MY_HOST "localhost" #define MY_USER "root" #define MY_PASSWORD "" #define MY_FIELD"naziv" #define MY_PORT "3306" #define MY_QUERY"SELECT URL from my_table as t1, my_table as t2 where t1.field = t2.field" int main (void) { Connection con(use_exceptions); try { ostrstream strbuf; unsigned int i=0; con.real_connect (MY_DATABASE,MY_HOST,MY_USER,MY_PASSWORD,3306,(int)0,60,NULL); Query query = con.query(); query << MY_QUERY; // ResUse res = query.use(); Row row; // strbuf << "delete from " << MY_TABLE << " where " << MY_FIELD << " in ("; // for UPDATE just replace the above DELETE FROM with UPDATE statement // for(0;row=res.fetch_row();i++) strbuf << row[0] << ","; if (!i) return 0; string output(strbuf.str()); output.erase(output.size()-1,1); output += ")"; query.exec((const string&)output); // cout << output << endl; return 0; } catch (BadQuery er) { cerr << "Error: " << er.error << " " << con.errnum() << endl; return -1; } } - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: C API help: mysql_fetch_row(mysql_res)
Konstantin Osipov writes: > Hi! > > Is this code buggy? > > ... > mysql_res = mysql_store_result(mysql); > > if (mysql_errno(mysql) == 0 && mysql_num_rows(mysql_res) > 2 && > mysql_num_fields(mysql_res) > 2) > { > MYSQL_ROW row1 = mysql_fetch_row(mysql_res); // can i fetch several rows > and then work with them? > MYSQL_ROW row2 = mysql_fetch_row(mysql_res); // > if (row1[0] == row2[0]) > printf("equal\n"); > } > > > HI! It is !! Konstantin, you send us a lot of buggy code. Nobody should be flamboyant with it's buggy code. What if mysql_store_result() returned NULL ?? Also, you would do much better by fetching rows like this: while ((row=mysql_fetch_row(mysql_res))) Also, again if you use properly MySQL++, without shortcuts (!), you will be much safer from the errors like the above. Regards, Sinisa __ _ _ ___ == MySQL AB /*/\*\/\*\ /*/ \*\ /*/ \*\ |*| Sinisa Milivojevic /*/ /*/ /*/ \*\_ |*| |*||*| mailto:[EMAIL PROTECTED] /*/ /*/ /*/\*\/*/ \*\|*| |*||*| Larnaca, Cyprus /*/ /*/ /*/\*\_/*/ \*\_/*/ |*| /*/^^^\*\^^^ /*/ \*\Developers Team - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
C API help: mysql_fetch_row(mysql_res)
Hi! Is this code buggy? ... mysql_res = mysql_store_result(mysql); if (mysql_errno(mysql) == 0 && mysql_num_rows(mysql_res) > 2 && mysql_num_fields(mysql_res) > 2) { MYSQL_ROW row1 = mysql_fetch_row(mysql_res); // can i fetch several rows and then work with them? MYSQL_ROW row2 = mysql_fetch_row(mysql_res); // if (row1[0] == row2[0]) printf("equal\n"); } - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
AW: С API help
Hello Konstantin, this code is buggy, because 'new' is not a valid C operator. And MYSQL is a struct not an object. The 'new' operator allocates memory for objects (C++). In C you?ve to use the malloc function. Take a look at the libmysqltest example, which comes with your distribution. Regards Andy > -Ursprungliche Nachricht- > Von: Konstantin Osipov [mailto:[EMAIL PROTECTED]] > Gesendet: Donnerstag, 8. Februar 2001 10:30 > An: [EMAIL PROTECTED] > Betreff: ó API help > > > Hi All! > > Is this code buggy? > -- > MYSQL* mysql = new MYSQL; > > mysql_init(mysql); > > mysql_real_connect(mysql, "localhost"); > /* some work*/ > mysql_close(mysql); > mysql_real_connect(mysql, "otherhost"); > /* some work*/ > mysql_close(mysql); > > delete mysql; > -- > In other words, if struct MYSQL allocated manually, should i call > mysql_init(mysql) after mysql_close(mysql) if i want to connect using this > struct to other database? > > > WBW, Konstantin > > > - > Before posting, please check: >http://www.mysql.com/manual.php (the manual) >http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail > <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: С API help
Konstantin Osipov writes: > Hi All! > > Is this code buggy? > -- > MYSQL* mysql = new MYSQL; > > mysql_init(mysql); > > mysql_real_connect(mysql, "localhost"); > /* some work*/ > mysql_close(mysql); > mysql_real_connect(mysql, "otherhost"); > /* some work*/ > mysql_close(mysql); > > delete mysql; > -- > In other words, if struct MYSQL allocated manually, should i call > mysql_init(mysql) after mysql_close(mysql) if i want to connect using this > struct to other database? > > > WBW, Konstantin > Yes, the above code is very buggy. Delete your first and last line and check the result from the subsequent functions !!! Regards, Sinisa __ _ _ ___ == MySQL AB /*/\*\/\*\ /*/ \*\ /*/ \*\ |*| Sinisa Milivojevic /*/ /*/ /*/ \*\_ |*| |*||*| mailto:[EMAIL PROTECTED] /*/ /*/ /*/\*\/*/ \*\|*| |*||*| Larnaka, Cyprus /*/ /*/ /*/\*\_/*/ \*\_/*/ |*| /*/^^^\*\^^^ /*/ \*\Developers Team - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
С API help
Hi All! Is this code buggy? -- MYSQL* mysql = new MYSQL; mysql_init(mysql); mysql_real_connect(mysql, "localhost"); /* some work*/ mysql_close(mysql); mysql_real_connect(mysql, "otherhost"); /* some work*/ mysql_close(mysql); delete mysql; -- In other words, if struct MYSQL allocated manually, should i call mysql_init(mysql) after mysql_close(mysql) if i want to connect using this struct to other database? WBW, Konstantin - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php