summaryrefslogtreecommitdiff
path: root/sqlplain/sqlite_util.py
diff options
context:
space:
mode:
Diffstat (limited to 'sqlplain/sqlite_util.py')
-rw-r--r--sqlplain/sqlite_util.py44
1 files changed, 0 insertions, 44 deletions
diff --git a/sqlplain/sqlite_util.py b/sqlplain/sqlite_util.py
deleted file mode 100644
index f33d395..0000000
--- a/sqlplain/sqlite_util.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import os
-from sqlplain.util import openclose, insert_rows
-from sqlplain import connect
-
-def get_info(conn, tname):
- """
- Returns a list of namedtuples [(cid, name, type, notnull, dflt_value, pk)]
- """
- return conn.execute('PRAGMA table_info(%s)' % tname)
-
-def load_file_sqlite(uri, tname, fname, mode, sep):
- import csv
- assert mode == 'c', "Only CSV files can be bulk imported in sqlite"
- csvfile = file(fname)
- conn = connect(uri)
- conn.execute('PRAGMA synchronous = OFF')
- try:
- n = insert_rows(conn, tname, csv.reader(csvfile, delimiter=sep))
- finally:
- csvfile.close()
- conn.execute('PRAGMA synchronous = ON')
- return n
-
-def get_kfields_sqlite(conn, tname):
- return [x.name for x in get_info(conn, tname) if x.pk]
-
-def get_tables_sqlite(conn):
- return [r.name for r in conn.execute('PRAGMA table_info')]
-
-def exists_table_sqlite(conn, tname):
- res = conn.execute('PRAGMA table_info(%s)' % tname)
- return res != -1
-
-def exists_db_sqlite(uri):
- fname = uri['database']
- return fname == ':memory:' or os.path.exists(fname)
-
-def drop_db_sqlite(uri):
- fname = uri['database']
- if fname != ':memory:':
- os.remove(fname)
-
-def create_db_sqlite(uri):
- "Do nothing, since the db is automatically created"