コード例 #1
0
class TestReplicationMaster(unittest.TestCase):
    def setUp(self):
        self.db = DBConnection()

    def test_create_new_data(self):
        # create new table
        self.db.conn.autocommit = True
        with self.db.cursor() as c:
            c.execute("""
                CREATE TABLE IF NOT EXISTS test_replication_table (
                    id integer not null
                        constraint pkey primary key,
                    geom geometry(Point, 4326),
                    name varchar(30),
                    alias varchar(30),
                    description varchar(255)
                );
                """)

            c.execute("""
                INSERT INTO test_replication_table (id, geom, name, alias, description)
                VALUES 
                (
                    1,
                    st_setsrid(st_point(107.6097, 6.9120), 4326),
                    'Bandung',
                    'Paris van Java',
                    'Asia-Africa conference was held here'                     
                ) ON CONFLICT DO NOTHING;
                """)
コード例 #2
0
class TestReplicationNode(unittest.TestCase):
    def setUp(self):
        self.db = DBConnection()

    def test_read_data(self):
        # create new table
        self.db.conn.autocommit = True
        with self.db.cursor() as c:
            c.execute("""
                SELECT * FROM test_replication_table;
                """)

            rows = c.fetchall()
            self.assertEqual(len(rows), 1)
コード例 #3
0
 def setUp(self):
     self.db = DBConnection()
コード例 #4
0
ファイル: test.py プロジェクト: SinaDashti/patenteProject
from os import environ
from tkinter import Tk
from dotenv import load_dotenv

from patenteSQL import ExamRawData
from gui.gui import Patente
from utils.utils import Consts
from utils.utils import (
    DBConnection, )

load_dotenv()

db = DBConnection(
    host=environ.get("HOST"),
    db_name=environ.get("DATABASE_NAME"),
    user=environ.get("MYSQL_USER"),
    password=environ.get("PASSWORD"),
)

if __name__ == "__main__":
    erd = ExamRawData(db, Consts)
    df = erd.df
    root = Tk()
    gui = Patente(root, df)
    root.mainloop()

# ls | grep -P "^[0-9]+.png" | xargs -d"\n" rm
コード例 #5
0
from os import environ
from dotenv import load_dotenv
from utils.utils import DBConnection

load_dotenv()

db = DBConnection(
    host=environ.get("HOST"),
    db_name=environ.get("DATABASE_NAME"),
    user=environ.get("MYSQL_USER"),
    password=environ.get("PASSWORD"),
)
db.create_connection()
db.delete_db("test_db")
db.close_connection()