Last active
July 18, 2018 03:48
-
-
Save BlogBlocks/f67b8ecf4589b531f408d798a4e650eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from time import sleep | |
| import sqlite3 | |
| import os, requests, sys, json | |
| import GISTkey | |
| username=GISTkey.gistkey()[0] | |
| password=GISTkey.gistkey()[1] | |
| database ="GISTstore/gist.db" | |
| conn = sqlite3.connect(database) | |
| c = conn.cursor() | |
| c.execute(""" | |
| CREATE VIRTUAL TABLE IF NOT EXISTS gist | |
| USING FTS4(content, description, filename); | |
| """) | |
| c.close() | |
| conn.close() | |
| conn = sqlite3.connect(database) | |
| conn.text_factory=str | |
| c = conn.cursor() | |
| PATH = "GISTstore/" | |
| filename = "post2gist.py" | |
| content=open(PATH+filename, 'r').read() | |
| r = requests.post('https://api.github.com/gists',json.dumps({'files':{filename:{"content":content}}}),auth=requests.auth.HTTPBasicAuth(username, password)) | |
| sleep(2) | |
| Url= (r.json()['html_url']) | |
| c.execute("INSERT INTO gist VALUES (?,?,?)", (content, Url, filename)) | |
| conn.commit() | |
| title = "Index" | |
| c.execute("INSERT INTO gist VALUES (?,?,?)", (title, Url, filename)) | |
| conn.commit() | |
| for row in c.execute('SELECT rowid, content, description, filename FROM gist \ | |
| WHERE filename MATCH ?', (filename,)): | |
| print Url,"\n",row[0],row[1],row[2],row[3] | |
| c.close() | |
| conn.close() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This file posts to gist.github and makes an entry to a SQLite database
This file uses ' import GISTkey '
To use without GISTkey use:
username = "githubname"
password = "password"