リビジョン | a1b18f3240057fb46b2538d4aa37c766f903f027 (tree) |
---|---|
日時 | 2023-03-30 05:49:41 |
作者 | Dreas Nielsen <dnielsen@inte...> |
コミッター | Dreas Nielsen |
Changed Postgres COPY command used with unquoted TSV data.
@@ -27,12 +27,12 @@ | ||
27 | 27 | # |
28 | 28 | # =============================================================================== |
29 | 29 | |
30 | -__version__ = "1.113.0" | |
31 | -__vdate = "2023-03-26" | |
30 | +__version__ = "1.113.1" | |
31 | +__vdate = "2023-03-29" | |
32 | 32 | |
33 | 33 | primary_vno = 1 |
34 | 34 | secondary_vno = 113 |
35 | -tertiary_vno = 0 | |
35 | +tertiary_vno = 1 | |
36 | 36 | |
37 | 37 | import os |
38 | 38 | import os.path |
@@ -4158,10 +4158,13 @@ | ||
4158 | 4158 | # Copy_from() requires a delimiter, but if there is none, feed it an |
4159 | 4159 | # ASCII unit separator, which, if it had been used for its intended purpose, |
4160 | 4160 | # should have been identified as the delimiter, so presumably it has not been used. |
4161 | - delim = csv_file_obj.delimiter if csv_file_obj.delimiter else chr(31) | |
4162 | - copy_cmd = "copy %s (%s) from stdin with (format csv, null '', delimiter '%s'" % (sq_name, input_col_list, delim) | |
4163 | - if csv_file_obj.quotechar: | |
4164 | - copy_cmd = copy_cmd + ", quote '%s'" % csv_file_obj.quotechar | |
4161 | + if csv_file_obj.delimiter == '\t' and csv_file_obj.quotechar is None: | |
4162 | + copy_cmd = "copy %s (%s) from stdin with (format text, null ''" % (sq_name, input_col_list) | |
4163 | + else: | |
4164 | + delim = csv_file_obj.delimiter if csv_file_obj.delimiter else chr(31) | |
4165 | + copy_cmd = "copy %s (%s) from stdin with (format csv, null '', delimiter '%s'" % (sq_name, input_col_list, delim) | |
4166 | + if csv_file_obj.quotechar: | |
4167 | + copy_cmd = copy_cmd + ", quote '%s'" % csv_file_obj.quotechar | |
4165 | 4168 | # psycopg2 or Postgres does not always do the encoding conversion correctly. |
4166 | 4169 | #if input_enc != self.encoding: |
4167 | 4170 | # copy_cmd = copy_cmd + ", encoding '%s'" % input_enc |
@@ -5,7 +5,7 @@ | ||
5 | 5 | long_description = f.read() |
6 | 6 | |
7 | 7 | setuptools.setup(name='execsql', |
8 | - version='1.113.0', | |
8 | + version='1.113.1', | |
9 | 9 | description="Runs a SQL script against a PostgreSQL, MS-Access, SQLite, MS-SQL-Server, MySQL, MariaDB, Firebird, or Oracle database, or an ODBC DSN. Provides metacommands to import and export data, copy data between databases, conditionally execute SQL and metacommands, and dynamically alter SQL and metacommands with substitution variables. Data can be exported in 18 different formats, including CSV, TSV, ODS, HTML, JSON, LaTeX, and Markdown tables, and using custom templates.", |
10 | 10 | author='Dreas Nielsen', |
11 | 11 | author_email='dreas.nielsen@gmail.com', |