mysql/example/private/run_batch_inserts.py
Ruben Perez 5e8992ba88 Client-side SQL formatting functions
Added format_sql, format_sql_to and basic_format_context
Boost.Charconv is now a mandatory dependency
Text queries are now locale-independent
any_connection::current_character_set now uses system::result
Added any_connection::format_opts
field_view, field and statement::bind now disallow character types
escape_string can now be used with any OutputString type
Added constant_string_view
character_set now uses string_view and span
set_character_set hardening

close #69
close #208
2024-02-15 16:02:39 +01:00

47 lines
1.2 KiB
Python

#!/usr/bin/python3
#
# Copyright (c) 2019-2023 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
from subprocess import run
import argparse
from typing import List
from os import path
# Helper to run the batch inserts example
_this_dir = path.abspath(path.dirname(path.realpath(__file__)))
class _Runner:
def __init__(self, exe: str, host: str) -> None:
self._exe = exe
self._host = host
def run(self, fname: str) -> None:
json_path = path.join(_this_dir, fname)
cmdline = [self._exe, 'example_user', 'example_password', self._host, json_path]
print(' + ', ' '.join(cmdline))
run(cmdline, check=True)
def main():
# Parse command line
parser = argparse.ArgumentParser()
parser.add_argument('executable')
parser.add_argument('host')
args = parser.parse_args()
# Build a runner
runner = _Runner(args.executable, args.host)
# Run the example with several combinations
runner.run('employees_single.json')
runner.run('employees_multiple.json')
if __name__ == '__main__':
main()