From 06fd7509fcf0ff672e7151706ef3ed5fb6008d67 Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Wed, 25 Jul 2007 10:14:23 +0000 Subject: [PATCH] skytools: docstring shuffle, hide/remove low-level/old stuff --- python/skytools/__init__.py | 10 +++++++ python/skytools/psycopgwrapper.py | 2 +- python/skytools/scripting.py | 4 +-- python/skytools/sqltools.py | 49 ++----------------------------- 4 files changed, 15 insertions(+), 50 deletions(-) diff --git a/python/skytools/__init__.py b/python/skytools/__init__.py index 06018721..f15fba5d 100644 --- a/python/skytools/__init__.py +++ b/python/skytools/__init__.py @@ -1,6 +1,7 @@ """Tools for Python database scripts.""" + from psycopgwrapper import * from config import * from dbstruct import * @@ -9,3 +10,12 @@ from scripting import * from sqltools import * from quoting import * +__all__ = (psycopgwrapper.__all__ + + config.__all__ + + dbstruct.__all__ + + gzlog.__all__ + + scripting.__all__ + + sqltools.__all__ + + quoting.__all__ ) + +del psycopgwrapper, config diff --git a/python/skytools/psycopgwrapper.py b/python/skytools/psycopgwrapper.py index 36b41124..043aabbd 100644 --- a/python/skytools/psycopgwrapper.py +++ b/python/skytools/psycopgwrapper.py @@ -9,7 +9,7 @@ Interface provided is psycopg1: """ -__all__ = ["QuotedString", "connect_database"] +__all__ = [] try: ##from psycopg2.psycopg1 import connect as _pgconnect diff --git a/python/skytools/scripting.py b/python/skytools/scripting.py index 058ff523..71cf3f89 100644 --- a/python/skytools/scripting.py +++ b/python/skytools/scripting.py @@ -8,8 +8,8 @@ from skytools.config import * from skytools.psycopgwrapper import connect_database import skytools.skylog -__all__ = ['daemonize', 'run_single_process', 'DBScript', - 'I_AUTOCOMMIT', 'I_READ_COMMITTED', 'I_SERIALIZABLE'] +__all__ = ['DBScript', 'I_AUTOCOMMIT', 'I_READ_COMMITTED', 'I_SERIALIZABLE'] +#__all__ += ['daemonize', 'run_single_process'] # # daemon mode diff --git a/python/skytools/sqltools.py b/python/skytools/sqltools.py index c0a057ca..2867a114 100644 --- a/python/skytools/sqltools.py +++ b/python/skytools/sqltools.py @@ -10,9 +10,8 @@ __all__ = [ "fq_name_parts", "fq_name", "get_table_oid", "get_table_pkeys", "get_table_columns", "exists_schema", "exists_table", "exists_type", "exists_function", "exists_language", "Snapshot", "magic_insert", - "db_copy_from_dict", "db_copy_from_list", "CopyPipe", "full_copy", - "DBObject", "DBSchema", "DBTable", "DBFunction", "DBLanguage", - "db_install", + "CopyPipe", "full_copy", "DBObject", "DBSchema", "DBTable", "DBFunction", + "DBLanguage", "db_install", ] @@ -230,50 +229,6 @@ def magic_insert(curs, tablename, data, fields = None, use_insert = 0): hdr = "%s (%s)" % (tablename, ",".join(fields)) curs.copy_from(buf, hdr) -def db_copy_from_dict(curs, tablename, dict_list, fields = None): - """Do a COPY FROM STDIN using list of dicts as source.""" - - if len(dict_list) == 0: - return - - if fields == None: - fields = dict_list[0].keys() - - buf = StringIO() - for dat in dict_list: - row = [] - for k in fields: - row.append(quote_copy(dat[k])) - buf.write("\t".join(row)) - buf.write("\n") - - buf.seek(0) - hdr = "%s (%s)" % (tablename, ",".join(fields)) - - curs.copy_from(buf, hdr) - -def db_copy_from_list(curs, tablename, row_list, fields): - """Do a COPY FROM STDIN using list of lists as source.""" - - if len(row_list) == 0: - return - - if fields == None or len(fields) == 0: - raise Exception('Need field list') - - buf = StringIO() - for dat in row_list: - row = [] - for i in range(len(fields)): - row.append(quote_copy(dat[i])) - buf.write("\t".join(row)) - buf.write("\n") - - buf.seek(0) - hdr = "%s (%s)" % (tablename, ",".join(fields)) - - curs.copy_from(buf, hdr) - # # Full COPY of table from one db to another # -- 2.39.5