Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Danny Chauhan
ecs-digital-tech-task
Commits
689be254
Commit
689be254
authored
Jun 06, 2020
by
Your Name
Browse files
added sql file tests and code to extract the version number as a list
parent
dbb51b4f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
0 deletions
+13
-0
DBpython.py
DBpython.py
+13
-0
SQL_script_directory/045.createtable.sql
SQL_script_directory/045.createtable.sql
+0
-0
SQL_script_directory/046.createtable.sql
SQL_script_directory/046.createtable.sql
+0
-0
No files found.
DBpython.py
View file @
689be254
...
...
@@ -12,6 +12,8 @@ db_host = sys.argv[2]
db_name
=
sys
.
argv
[
3
]
db_password
=
sys
.
argv
[
4
]
import
os
import
re
import
mysql.connector
from
mysql.connector
import
errorcode
...
...
@@ -26,6 +28,17 @@ try:
data
=
cursor
.
fetchone
()
print
(
"Current Database version : %s "
%
data
)
#could do a nested for loop hear the regex.findall(f) is of type list
for
root
,
dirs
,
files
in
os
.
walk
(
"SQL_script_directory"
):
for
f
in
files
:
if
f
.
endswith
(
".sql"
):
regex
=
re
.
compile
(
r
'\d+'
)
test
=
regex
.
findall
(
f
)
print
(
regex
.
findall
(
f
))
print
(
type
(
test
))
# print(os.path.join(root, f))
except
mysql
.
connector
.
Error
as
err
:
if
err
.
errno
==
errorcode
.
ER_ACCESS_DENIED_ERROR
:
print
(
"Something is wrong with your user name or password"
)
...
...
SQL_script_directory/045.createtable.sql
0 → 100644
View file @
689be254
SQL_script_directory/046.createtable.sql
0 → 100644
View file @
689be254
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