summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwr61 <wr61@e10066b5-e1e2-0310-b819-94efdf66514b>2005-03-04 11:08:07 +0000
committerwr61 <wr61@e10066b5-e1e2-0310-b819-94efdf66514b>2005-03-04 11:08:07 +0000
commit4b59b0193b21c7c6a289a20cebe0b0a6edbe244f (patch)
treec742c20a0f4b9a83bb9eefd9785bc409e721a854
parentb31cf6b3f9744b5cb199a8970dbe3bdedece9c6c (diff)
downloadvdr-plugin-muggle-4b59b0193b21c7c6a289a20cebe0b0a6edbe244f.tar.gz
vdr-plugin-muggle-4b59b0193b21c7c6a289a20cebe0b0a6edbe244f.tar.bz2
more flexible creation of database
git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/branches/0.1.3-wr@536 e10066b5-e1e2-0310-b819-94efdf66514b
-rw-r--r--mg_mysql.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/mg_mysql.c b/mg_mysql.c
index ba3e50f..4266c27 100644
--- a/mg_mysql.c
+++ b/mg_mysql.c
@@ -85,12 +85,6 @@ mgmySql::~mgmySql()
static char *db_cmds[] =
{
- "DROP DATABASE IF EXISTS GiantDisc",
- "CREATE DATABASE GiantDisc",
-#ifdef HAVE_SERVER
- "grant all privileges on GiantDisc.* to vdr@localhost;",
-#endif
- "use GiantDisc;",
"drop table if exists album;",
"CREATE TABLE album ( "
"artist varchar(255) default NULL, "
@@ -365,13 +359,28 @@ void mgmySql::Create()
createtime=time(0);
// create database and tables
mgDebug(1,"Dropping and recreating database %s",the_setup.DbName);
+ if (mysql_query(m_db,"DROP DATABASE IF EXISTS GiantDisc;"))
+ {
+ mgWarning("Cannot drop existing database:%s",mysql_error (m_db));
+ return;
+ }
+ if (mysql_query(m_db,"CREATE DATABASE GiantDisc;"))
+ {
+ mgWarning("Cannot create database:%s",mysql_error (m_db));
+ return;
+ }
+#ifdef HAVE_SERVER
+ mysql_query(m_db,"grant all privileges on GiantDisc.* to vdr@localhost;");
+ // ignore error. If we can create the data base, we can do everything
+ // with it anyway.
+#endif
+ mysql_query(m_db,"use GiantDisc;");
int len = sizeof( db_cmds ) / sizeof( char* );
for( int i=0; i < len; i ++ )
{
if (mysql_query (m_db, db_cmds[i]))
{
- mgWarning("SQL Error in %s: %s",db_cmds[i],mysql_error (m_db));
- std::cout<<"ERROR in " << db_cmds[i] <<std::endl;
+ mgWarning("%20s: %s",db_cmds[i],mysql_error (m_db));
mysql_query(m_db, "DROP DATABASE IF EXISTS GiantDisc;"); // clean up
return;
}