Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
web app
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ICNML
web app
Commits
7df017a3
Commit
7df017a3
authored
5 years ago
by
Marco De Donno
Browse files
Options
Downloads
Patches
Plain Diff
Check for the fields type in the sql_insert_generate() function
parent
2106288b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
functions.py
+6
-0
6 additions, 0 deletions
functions.py
with
6 additions
and
0 deletions
functions.py
+
6
−
0
View file @
7df017a3
...
@@ -117,6 +117,12 @@ def pil2buffer( img, format ):
...
@@ -117,6 +117,12 @@ def pil2buffer( img, format ):
return
buff
return
buff
def
sql_insert_generate
(
table
,
fields
,
returning
=
None
):
def
sql_insert_generate
(
table
,
fields
,
returning
=
None
):
if
isinstance
(
fields
,
(
str
)
):
fields
=
[
fields
]
if
not
isinstance
(
fields
,
(
list
,
tuple
,
)
):
raise
Exception
(
"
list or tuple needed as fields
"
)
f
=
"
,
"
.
join
(
fields
)
f
=
"
,
"
.
join
(
fields
)
place_holder
=
"
,
"
.
join
(
[
"
%s
"
]
*
len
(
fields
)
)
place_holder
=
"
,
"
.
join
(
[
"
%s
"
]
*
len
(
fields
)
)
sql
=
"
INSERT INTO {} ({}) VALUES ({})
"
.
format
(
table
,
f
,
place_holder
)
sql
=
"
INSERT INTO {} ({}) VALUES ({})
"
.
format
(
table
,
f
,
place_holder
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment