References
Documentation extracted from the docstrings.
Fbexport Tool
A tool to export data from a firebird database in bulk. Run fbexport-tool.py -h
to
see details on how to use.
The input to this program is an fdb database and a text file with a list of space separated names of tables to be exported or a list of the names of such tables.
This is a thin wrap around fbexport
, so you will need to install it before.
In case your OS does not ship with this programm, see
http://www.firebirdfaq.org/fbexport.php
export_cmd(database, destination, table, password='masterkey')
return a fbexport
statement suitable for use in the terminal.
Parameters
@param database: Database location or path. @password @destination: Output location or path. @table: The name of the table to export.
Returns
A string representing the command that should be executed to commit the export.
Example
export_cmd('database.fbd', destination='database.csv', table='MYTABLE') ['fbexport', '-H', '', '-Sc', '-J', 'Y-M-D', '-D', 'database.fbd', '-F', 'database.csv', '-V', 'MYTABLE']
Source code in fbexport_tool.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
iter_words(stream)
Return an iterator to the words contained in stream
.
Example
from io import StringIO buffer = StringIO(initial_value=' word1 word2 \n word3 ') [w for w in iter_words(buffer)] ['word1', 'word2', 'word3']
Source code in fbexport_tool.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
outputdir_filename(database, when)
Returns the name of the output directory in format YYYY-MM-DD-hh-mm-ss-database
with the database suffix removed.
If the database name has spaces they are replaced by underscores (i.e. "database name".fdb
is replaced by database_name
)
Example
from datetime import datetime when = datetime(2023, 1, 1, 14,0,0) outputdir_filename('database.fdb', when) '2023-01-01-14-00-00-database'
outputdir_filename('another database.fdb', when) '2023-01-01-14-00-00-another_database'
Source code in fbexport_tool.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
table_csv_filename(tablename)
Returns a sanitized version of the name of a table. The name is converted to lowercase, any space is replaced by underscores and special caracters like quotes are stripped away.
Examples
table_csv_filename('TABLE') 'table.csv'
table_csv_filename('A TABLE') 'a_table.csv'
table_csv_filename('"Decimal"') 'decimal.csv'
Source code in fbexport_tool.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|