def forwards(self, orm):
     
     # Adding model 'Score'
     db.create_table('djangoratings_score', (
         ('id', orm['djangoratings.Score:id']),
         ('content_type', orm['djangoratings.Score:content_type']),
         ('object_id', orm['djangoratings.Score:object_id']),
         ('key', orm['djangoratings.Score:key']),
         ('score', orm['djangoratings.Score:score']),
         ('votes', orm['djangoratings.Score:votes']),
     ))
     db.send_create_signal('djangoratings', ['Score'])
     
     # Adding model 'Vote'
     db.create_table('djangoratings_vote', (
         ('id', orm['djangoratings.Vote:id']),
         ('content_type', orm['djangoratings.Vote:content_type']),
         ('object_id', orm['djangoratings.Vote:object_id']),
         ('key', orm['djangoratings.Vote:key']),
         ('score', orm['djangoratings.Vote:score']),
         ('user', orm['djangoratings.Vote:user']),
         ('ip_address', orm['djangoratings.Vote:ip_address']),
         ('date_added', orm['djangoratings.Vote:date_added']),
         ('date_changed', orm['djangoratings.Vote:date_changed']),
     ))
     db.send_create_signal('djangoratings', ['Vote'])
     
     # Creating unique_together for [content_type, object_id, key, user, ip_address] on Vote.
     db.create_unique('djangoratings_vote', ['content_type_id', 'object_id', 'key', 'user_id', 'ip_address'])
     
     # Creating unique_together for [content_type, object_id, key] on Score.
     db.create_unique('djangoratings_score', ['content_type_id', 'object_id', 'key'])
Example #2
0
def create_cam_table():
    """
    The C{cam} table defines a mapping between camera names and C{cam_id}s.
    """
    drop_table("image")
    create_table("cam",
                 [id_field("id", "TINYINT"),
                  "name CHAR(3) NOT NULL UNIQUE"])
Example #3
0
def create_starcount_table():
    """
    The C{starcount} table stores the number of stars identified by AptPhot in
    each image.
    """
    create_table("starcount", 
                 [int_field("image_id"),
                  int_field("nstars"),
                  fk_field("image_id", "image(id)")])
Example #4
0
def create_unzip_table():
    """
    The C{unzip} table keeps track of which images have been unzipped and the
    resulting filenames.
    """
    create_table("unzip", 
                 [pk_field("image_id", "INT"),
                  type_field("success", "TINYINT"),
                  str_field("outputfile", 50, True),
                  fk_field("image_id", "image(id)")])
Example #5
0
def create_flat_table():
    """
    The C{flat} table keeps track of which images have been flat fielded and
    where the names of the resulting images.
    """
    create_table("flat", 
                 [pk_field("image_id", "INT"),
                  str_field("flatfile", 25),
                  str_field("outputfile", 50),
                  fk_field("image_id", "image(id)")])
Example #6
0
def create_imstat_table():
    """
    The C{imstat} table stores the result of running C{imstat} on each image.
    """
    create_table("imstat", 
                 [pk_field("image_id", "INT"),
                  int_field("min"),
                  int_field("max"),
                  int_field("mean"),
                  int_field("stddev"),
                  fk_field("image_id", "image(id)")])
Example #7
0
def create_star_table():
    """
    The C{star} table keeps track of the catalogue stars which are identified by
    AptPhot.
    """
    drop_table("phot")
    create_table("star", 
                 [id_field("star_id", "INT"),
                  int_field("cat_id", True),
                  float_field("ra"),
                  float_field("decl")])
Example #8
0
def create_astrom_table():
    """
    The C{astrom} table records the results of running C{AptAstrom} on each
    image.
    """
    create_table("astrom", 
                 [pk_field("image_id", "INT"),
                  type_field("success", "TINYINT"),
                  float_field("smag"),
                  float_field("zmag"),
                  float_field("sky"),
                  fk_field("image_id", "image(id)")])
Example #9
0
def create_image_table():
    """
    The C{image} table defines a mapping between filenames and C{image_id}s.
    These C{image_id}s are used as the primary method of identifying images in
    the rest of the system.
    """
    create_table("image", 
                 [id_field("id", "INT"),
                  str_field("filename", 100, True),
                  str_field("basename", 50, True),
                  type_field("cam_id", "TINYINT"),
                  type_field("time", "DATETIME"),
                  fk_field("cam_id", "cam(id)")])
Example #10
0
def create_phot_table():
    """
    The C{phot} table keeps track of the individual stars which are identified
    in each image by AptPhot.
    """
    create_table("phot", 
                 [int_field("image_id"),
                  int_field("star_id"),
                  float_field("vmag"),
                  float_field("smag"),
                  float_field("mag3"),
                  float_field("mag4"),
                  str_field("err3", 100),
                  str_field("err4", 100),
                  float_field("X"),
                  float_field("Y"),
                  fk_field("star_id", "star(star_id)"),
                  fk_field("image_id", "image(id)"),
                  "KEY (image_id, star_id)"])
Example #11
0
def create_header_table():
    """
    The C{header} table stores a selection of FITS header fields from each image.
    """
    create_table("header", 
                 [pk_field("image_id", "INT"),
                  float_field("temp"),
                  float_field("exposure"),
                  type_field("time", "DATETIME"),
                  float_field("sunzd"),
                  float_field("moonzd"),
                  float_field("moondist"),
                  float_field("moonphase"),
                  float_field("moonmag"),
                  float_field("ra"),
                  float_field("decl"),
                  float_field("lst"),
                  float_field("jd"),
                  float_field("crval1"),
                  float_field("crval2"),
                  fk_field("image_id", "image(id)")])
Example #12
0
File: tar.py Project: ajrbyers/tar
def setup():
	conn = db.connection()
	db.create_table(conn)
Example #13
0
def get_last_row_bm_date():
    sqlite_path = data_path(silent=True)
    with db.connect(sqlite_path) as fafi:
        db.create_table(fafi)

        return db.last_row_bm_date(fafi)
Example #14
0
def init_profile(con):
	create_table(con,"balance","(id INTEGER PRIMARY KEY, timecode, idr, btc)")
	create_table(con,"trades","(id INTEGER PRIMARY KEY, trade_id, timecode, market, trans_type, price, amount, fee, status)")
	create_table(con,"history","(id INTEGER PRIMARY KEY, trade_id, timecode, opentime, closetime, openprice, closeprice,openamount, closeamount, profit, percent_profit)")
Example #15
0
 def create_table(self):
     db.create_table()
Example #16
0
def setup_cloud_resources() -> None:
    create_s3_bucket()
    create_table()
    create_queue()
Example #17
0
def main():
    if not os.path.exists(config.db_name):
        db.create_db(config.db_name)
        db.create_table(config.db_name, config.block_tx_table_name)

    assign_work(config.block_tx_table_name)
Example #18
0
def create_table_orm():
    create_table()
Example #19
0
def setup():
    # any tasks the program needs to complete before it can start
    db.create_table()
Example #20
0
File: tar.py Project: ajrbyers/tar
def setup():
    conn = db.connection()
    db.create_table(conn)
Example #21
0
        now = datetime.now()
        start_date = now - timedelta(days=7)
        # set end_date one day before current datetime to catch as much replies as possible
        end_date = now - timedelta(days=1)
        context_free = False
    else:  # if country == "GR"
        database = os.path.join(dir_path, "databases",
                                "twitter_without_cntx_gr.db")
        mps_file = "gr_candidate_meps.csv"
        start_date = None
        context_free = True

    # create sqlite db and create tables
    if not os.path.exists(database):
        db.create_db(database)
    # create a database connection
    conn = db.create_connection(database)
    if conn is not None:
        # create twitter_user table
        db.create_table(conn, db.sql_create_user_table)
        # create tweets table
        db.create_table(conn, db.sql_create_tweet_table)
    else:
        print("Error! cannot create the database connection.")
    get_tweets(mps_file, database, country, context_free, start_date, end_date)

    # stream_tweets()
    # stream_tweets_referring_meps()
    # plot_followers(database)
    # search_tweets_referring_meps(database)
Example #22
0
def init_db():
    with app.app.app_context():
        db.create_table(app.get_db())
Example #23
0
def bic_details(bic):
    print(f'Requesting {bic} ...')
    page = requests.get(bic)
    soup = BeautifulSoup(page.content, 'html.parser')
    data = {}
    for row in soup.select('tr > td > strong'):
        data[row.get_text()] = row.parent.find_next_sibling().get_text().strip(
        )
    return data


# BIC codes
sql_create_bic_table = """ CREATE TABLE IF NOT EXISTS bic (
                                    swift text PRIMARY KEY,
                                    country text,
                                    bank text,
                                    branch text,
                                    city text,
                                    zipcode text,
                                    address text
                                ); """

conn = create_connection('swift.db')
create_table(conn, sql_create_bic_table)
for country in countries:
    for bic in bics_from_country(country, []):
        detail = bic_details(bic)
        create_bic(conn, tuple(detail.values()))
    conn.commit()

conn.close()
Example #24
0
        elif option == "3":
            rows = db.select_all(conn)
            if not rows:
                print("no passwords stored yet")
            else:
                display_pwds(cipher, rows)
                submenu(conn, cipher)

        elif option == "4":
            print("Bye!")
            break

        else:  #error handle
            print("no such option")


if __name__ == '__main__':
    conn = db.connect_db(r"pwds.db")
    db.create_table(conn)

    welcomemsg()
    print(
        "If you are the first time here, please use the following key and save it to a safe place."
    )
    print(crypt.new_key().decode(), '\n')
    print(
        "You will need to enter this key to get your passwords in the future")
    input("If you already got your encryption key, please ignore this message")

    key = get_key()
    menu(conn, key)
Example #25
0
from tkinter import simpledialog
from ttkthemes import themed_tk as ttkt
import random
from datetime import datetime
from datetime import timedelta
from datetime import date
from dateutil.parser import parse
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import tkcalendar
from tkcalendar import Calendar, DateEntry
from start import username

import db
db.create_table()
db.create_table2()
db.create_table3()
db.create_table4()

tasks_due=[]


root = ttkt.ThemedTk()     #Main window
tname=db.get_theme(username)
if len(tname)==0 :         #If youare opening for the first time default theme will be appear.
    root.set_theme('radiance')
else:                      #else the theme last you change will be appear.
    root.set_theme(tname[0][0])
root.title("Task Diary")
columns = ("task_name", "priority_of_task", "category", "is_done","deadline")
Example #26
0
def list_user():
    db.create_table()
    users=db.all_users()
    return render_template('list.html',users=users)
Example #27
0
import ConfigParser
import re
import os.path
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
import time
# -------------------------------------------------
import db
import hud
import wx

class MyHandler(FileSystemEventHandler):

    def on_modified(self, event):
        print event.event_type
        evt = hud.App.TableUpdateEvent(src_path=event.src_path)
        wx.PostEvent(wx.GetApp().TopWindow, evt)
        return

if __name__ == '__main__':
    db.create_table()
    app = hud.App(False)
    observer = Observer()
    observer.schedule(MyHandler(), "C:\Users\cyka\AppData\Roaming\PacificPoker\HandHistory\Lufftre")
    observer.start()
    try:
        app.MainLoop()
    finally:
        observer.join()
        print 'done'
Example #28
0
 def save_photos_db(self):
     cur, conn, dbname = db.connect_database()
     db.create_table(cur, conn)
     for k, v in self.sorted_photos.items():
         db.add_photos(k, v, cur, conn)
     print(f'Photos have been saved in database {dbname}!')
        'mysql_engine': DbVars.ENGINE,
        'mysql_charset': DbVars.CHARSET,
        'mysql_collate': DbVars.COLLATE
    }

    id = Column(INTEGER(unsigned=True), primary_key=True, autoincrement=True)

    parent_id = Column(INTEGER(unsigned=True),
                       ForeignKey('parent.id', ondelete="CASCADE"))

    name = Column(VARCHAR(256), unique=True)

    parent = relationship('Parent', back_populates='children')


create_table()


def insert_test_data():
    with transaction_context() as session:
        p1 = Parent()
        p1.name = "p1"

        c1 = Child()
        c1.name = "c1"
        c2 = Child()
        c2.name = "c2"

        p1.childs = [c1, c2]

        session.add(p1)