Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
emulab-stable
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
emulab
emulab-stable
Commits
bd117a07
Commit
bd117a07
authored
Sep 27, 2011
by
Leigh Stoller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redo my DBexists() addition since it got conflicted away by last
revision.
parent
179c189f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
db/emdbi.pm.in
db/emdbi.pm.in
+49
-0
No files found.
db/emdbi.pm.in
View file @
bd117a07
...
...
@@ -66,6 +66,25 @@ sub pid($) { return $_[0]->{'PID'}; };
sub
dbh
($)
{
return
$
_
[
0
]->{
'DBH'
};
};
sub
dbname
($)
{
return
$
_
[
0
]->{
'DBNAME'
};
};
#
#
Check
for
existence
of
DB
#
sub
DBExists
($$)
{
my
($
class
,
$
dbname
)
=
@
_
;
require
Mysql
;
$
Mysql
::
QUIET
=
1
;
my
$
dbh
=
Mysql
->
connect
(
"localhost"
);
return
undef
if
(
!defined($dbh));
my
@
dbs
=
$
dbh
->
listdbs
();
return
1
if
(
grep
{$
_
eq
$
dbname
}
@
dbs
);
return
0
;
}
#
#
Need
to
wrap
the
return
value
.
See
below
.
#
...
...
@@ -135,6 +154,21 @@ sub pid($) { return $_[0]->{'PID'}; };
sub
dbh
($)
{
return
$
_
[
0
]->{
'DBH'
};
};
sub
dbname
($)
{
return
$
_
[
0
]->{
'DBNAME'
};
};
#
#
Check
for
existence
of
DB
#
sub
DBExists
($$)
{
my
($
class
,
$
dbname
)
=
@
_
;
require
DBI
;
my
@
dbs
=
DBI
->
data_sources
(
"mysql"
);
return
1
if
(
grep
{$
_
eq
"DBI:mysql:$dbname"
}
@
dbs
);
return
0
;
}
#
#
Wrap
query
for
proper
DBI
syntax
.
#
...
...
@@ -354,6 +388,21 @@ $DBErrorString = "";
my
$
queryCount
=
0
;
#
#
Does
DB
exist
yet
.
#
sub
DBExists
($)
{
my
($
dbname
)
=
@
_
;
if
($
DBCONN_USEDBI
)
{
return
emdbi_wrapper
::
DBI
->
DBExists
($
dbname
);
}
else
{
return
emdbi_wrapper
::
Mysql
->
DBExists
($
dbname
);
}
}
sub
TBDBConnect
($$)
{
my
($
dbnum
,
$
dbname
)
=
@
_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment