We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Would like to have an example which documents how to perform bulk insert
INSERT INTO links (url, name) VALUES ('https://www.google.com','Google'), ('https://www.yahoo.com','Yahoo'), ('https://www.bing.com','Bing');
The text was updated successfully, but these errors were encountered:
Working Code:
from jinjasql import JinjaSql urls = [ ("google", "https://google.com"), ("yahoo", "https://yahoo.com"), ("fb", "https://facebook.com"), ("twitter", "https://twitter.com"), ] template = ''' INSERT INTO links(name, url) VALUES {% for url in urls %} ( {{url[0]}}, {{url[1]}} ) {% endfor %} ''' j = JinjaSql(param_style="qmark") query, bindparams = j.prepare_query(template, {"urls": urls}) print(query) print(bindparams)
Should print this:
INSERT INTO links(name, url) VALUES (?, ?) (?, ?) (?, ?) (?, ?) ['google', 'https://google.com', 'yahoo', 'https://yahoo.com', 'fb', 'https://facebook.com', 'twitter', 'https://twitter.com']
Sorry, something went wrong.
@sripathikrishnan Thanks a ton! :-) Can i add this to readme or wiki?
No branches or pull requests
Would like to have an example which documents how to perform bulk insert
Desired output
The text was updated successfully, but these errors were encountered: