Example #1
0
def test_insert_float():

    # Ensure the database is in a known state before calling the function we're
    # testing
    with db_con.cursor() as cur:
        cur.execute(slurp('./test/fixtures/state_empty.sql'))

    # Attempt to insert a float (should be converted to an integer)
    insert(db_conf, 42.6)

    # Inspect the state of the database and make some assertions
    with db_con.cursor() as cur:

        # Check the rows in the table after insert has been called
        cur.execute("""SELECT * from public.numbers;""")
        rows = cur.fetchall()
        # Expect a single row with the value of 43 (our float is converted to
        # an integer)
        eq_(rows, [(43, )])
def test_insert_float():

    # Ensure the database is in a known state before calling the function we're
    # testing
    with db_con.cursor() as cur:
        cur.execute(slurp('./test/fixtures/state_empty.sql'))

    # Attempt to insert a float (should be converted to an integer)
    insert(db_conf, 42.6)

    # Inspect the state of the database and make some assertions
    with db_con.cursor() as cur:

        # Check the rows in the table after insert has been called
        cur.execute("""SELECT * from public.numbers;""")
        rows = cur.fetchall()
        # Expect a single row with the value of 43 (our float is converted to
        # an integer)
        eq_(rows, [(43,)])
Example #3
0
def test_insert_int():

    # Ensure the database is in a known state before calling the function we're
    # testing
    with db_con.cursor() as cur:
        cur.execute(slurp('./test/fixtures/state_empty.sql'))

    # Attempt to insert an integer
    insert(db_conf, 42)

    # Inspect the state of the database and make some assertions
    with db_con.cursor() as cur:

        # Check the rows in the table after insert has been called
        cur.execute("""SELECT * from public.numbers;""")
        rows = cur.fetchall()
        # Using the eq_ function from nose.tools allows us to assert that
        # complex types are equal. Here we are saying that we expect a single
        # row with a single value of 42
        eq_(rows, [(42, )])
def test_insert_int():

    # Ensure the database is in a known state before calling the function we're
    # testing
    with db_con.cursor() as cur:
        cur.execute(slurp('./test/fixtures/state_empty.sql'))

    # Attempt to insert an integer
    insert(db_conf, 42)

    # Inspect the state of the database and make some assertions
    with db_con.cursor() as cur:

        # Check the rows in the table after insert has been called
        cur.execute("""SELECT * from public.numbers;""")
        rows = cur.fetchall()
        # Using the eq_ function from nose.tools allows us to assert that
        # complex types are equal. Here we are saying that we expect a single
        # row with a single value of 42
        eq_(rows, [(42,)])
from app import insert, select
import numpy
import pandas as pd
# insert function insert data from frames  to SQL user table
insert(
)  # this function call when you want to insert data from data frame to sql tables
arr = select()
## this function converts arr values into data frame
sqlData = pd.DataFrame(data=arr, columns="ID Gendre Age Income Spend".split())
print(sqlData)