Subdomain Posts
None | 5 days ago
Python | 21 days ago
C# | 26 days ago
C# | 27 days ago
C# | 28 days ago
C# | 28 days ago
C | 172 days ago
Python | 175 days ago
C++ | 196 days ago
PHP | 260 days ago
Recent Posts
None | 12 sec ago
mIRC | 18 sec ago
None | 24 sec ago
C# | 29 sec ago
None | 51 sec ago
mIRC | 56 sec ago
None | 57 sec ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
By IceDragon on the 25th of Mar 2009 11:37:10 AM
Download |
Raw |
Embed |
Report
#!/usr/bin/python
# .-=[ sql3-to-tab ]=======================================================-. #
# | SQLite3 to Tab-Delimited TXT Converter by IceDragon of QuickFox.org | #
# |-------------------------------------------------------------------------| #
# | This script converts an SQLite3 database to a tab-delimited text file. | #
# | Particularly useful to export data from a database into applications | #
# | that allow it. | #
# |-------------------------------------------------------------------------| #
# | NOTE: This script does not yet support \n characters in entries! | #
# '-=============================================================[ 1.0.0 ]=-' #
###--# Imports #--###
import sqlite3
from sys import argv
__author__ = "Kyle Storm <icedragon@quickfox.org>"
###--# Entrypoint #--###
def main( argv ):
# Handling command-line parameters.
if len(argv) < 3:
print "Syntax: %s <db_file> <table> [out_file]" % argv[0]
raise SystemExit(0)
cmd, db_file, table = argv[:3]
if len(argv) > 3:
out_file = argv[3]
else:
out_file = db_file.rsplit('.',1)[0] + '.txt'
# Getting data from the database.
data = sqlite3.connect( db_file ).execute("SELECT * FROM %s" % table).fetchall()
# Opening output file.
fd = open( out_file, 'w' )
counter = 0
for entry in data:
# Ensuring the entry list is all strings. join() would fail otherwise.
entry_list = []
for element in entry:
entry_list += [ str(element) ]
fd.write( "\t".join( entry_list ) + "\n" )
counter += 1
fd.close()
print "%d entries exported to %s" % (counter,out_file)
raise SystemExit(0)
###--# Initialization #--###
if __name__ == "__main__":
main( argv )
Submit a correction or amendment below.
Make A New Post