Python pandas.io.sql.has_table() Examples
The following are 30
code examples of pandas.io.sql.has_table().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pandas.io.sql
, or try the search function
.

Example #1
Source File: test_sql.py From recruit with Apache License 2.0 | 6 votes |
def _to_sql_append(self): # Nuke table just in case self.drop_table('test_frame1') self.pandasSQL.to_sql( self.test_frame1, 'test_frame1', if_exists='fail') # Add to table again self.pandasSQL.to_sql( self.test_frame1, 'test_frame1', if_exists='append') assert self.pandasSQL.has_table('test_frame1') num_entries = 2 * len(self.test_frame1) num_rows = self._count_rows('test_frame1') assert num_rows == num_entries self.drop_table('test_frame1')
Example #2
Source File: test_sql.py From recruit with Apache License 2.0 | 6 votes |
def _to_sql_method_callable(self): check = [] # used to double check function below is really being used def sample(pd_table, conn, keys, data_iter): check.append(1) data = [dict(zip(keys, row)) for row in data_iter] conn.execute(pd_table.table.insert(), data) self.drop_table('test_frame1') self.pandasSQL.to_sql(self.test_frame1, 'test_frame1', method=sample) assert self.pandasSQL.has_table('test_frame1') assert check == [1] num_entries = len(self.test_frame1) num_rows = self._count_rows('test_frame1') assert num_rows == num_entries # Nuke table self.drop_table('test_frame1')
Example #3
Source File: test_sql.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def _to_sql_method_callable(self): check = [] # used to double check function below is really being used def sample(pd_table, conn, keys, data_iter): check.append(1) data = [dict(zip(keys, row)) for row in data_iter] conn.execute(pd_table.table.insert(), data) self.drop_table('test_frame1') self.pandasSQL.to_sql(self.test_frame1, 'test_frame1', method=sample) assert self.pandasSQL.has_table('test_frame1') assert check == [1] num_entries = len(self.test_frame1) num_rows = self._count_rows('test_frame1') assert num_rows == num_entries # Nuke table self.drop_table('test_frame1')
Example #4
Source File: test_sql.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def _to_sql_append(self): # Nuke table just in case self.drop_table('test_frame1') self.pandasSQL.to_sql( self.test_frame1, 'test_frame1', if_exists='fail') # Add to table again self.pandasSQL.to_sql( self.test_frame1, 'test_frame1', if_exists='append') assert self.pandasSQL.has_table('test_frame1') num_entries = 2 * len(self.test_frame1) num_rows = self._count_rows('test_frame1') assert num_rows == num_entries self.drop_table('test_frame1')
Example #5
Source File: test_sql.py From twitter-stock-recommendation with MIT License | 6 votes |
def _to_sql_append(self): # Nuke table just in case self.drop_table('test_frame1') self.pandasSQL.to_sql( self.test_frame1, 'test_frame1', if_exists='fail') # Add to table again self.pandasSQL.to_sql( self.test_frame1, 'test_frame1', if_exists='append') assert self.pandasSQL.has_table('test_frame1') num_entries = 2 * len(self.test_frame1) num_rows = self._count_rows('test_frame1') assert num_rows == num_entries self.drop_table('test_frame1')
Example #6
Source File: test_sql.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def _to_sql_append(self): # Nuke table just in case self.drop_table('test_frame1') self.pandasSQL.to_sql( self.test_frame1, 'test_frame1', if_exists='fail') # Add to table again self.pandasSQL.to_sql( self.test_frame1, 'test_frame1', if_exists='append') assert self.pandasSQL.has_table('test_frame1') num_entries = 2 * len(self.test_frame1) num_rows = self._count_rows('test_frame1') assert num_rows == num_entries self.drop_table('test_frame1')
Example #7
Source File: test_sql.py From vnpy_crypto with MIT License | 6 votes |
def _to_sql_append(self): # Nuke table just in case self.drop_table('test_frame1') self.pandasSQL.to_sql( self.test_frame1, 'test_frame1', if_exists='fail') # Add to table again self.pandasSQL.to_sql( self.test_frame1, 'test_frame1', if_exists='append') assert self.pandasSQL.has_table('test_frame1') num_entries = 2 * len(self.test_frame1) num_rows = self._count_rows('test_frame1') assert num_rows == num_entries self.drop_table('test_frame1')
Example #8
Source File: test_sql.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_create_and_drop_table(self): temp_frame = DataFrame( {'one': [1., 2., 3., 4.], 'two': [4., 3., 2., 1.]}) self.pandasSQL.to_sql(temp_frame, 'drop_test_frame') assert self.pandasSQL.has_table('drop_test_frame') self.pandasSQL.drop_table('drop_test_frame') assert not self.pandasSQL.has_table('drop_test_frame')
Example #9
Source File: test_sql.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_create_table(self): temp_conn = self.connect() temp_frame = DataFrame( {'one': [1., 2., 3., 4.], 'two': [4., 3., 2., 1.]}) pandasSQL = sql.SQLDatabase(temp_conn) pandasSQL.to_sql(temp_frame, 'temp_frame') assert temp_conn.has_table('temp_frame')
Example #10
Source File: test_sql.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_drop_table(self): temp_conn = self.connect() temp_frame = DataFrame( {'one': [1., 2., 3., 4.], 'two': [4., 3., 2., 1.]}) pandasSQL = sql.SQLDatabase(temp_conn) pandasSQL.to_sql(temp_frame, 'temp_frame') assert temp_conn.has_table('temp_frame') pandasSQL.drop_table('temp_frame') assert not temp_conn.has_table('temp_frame')
Example #11
Source File: test_sql.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def _to_sql(self): self.drop_table('test_frame1') self.pandasSQL.to_sql(self.test_frame1, 'test_frame1') assert self.pandasSQL.has_table('test_frame1') # Nuke table self.drop_table('test_frame1')
Example #12
Source File: test_sql.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def _to_sql_fail(self): self.drop_table('test_frame1') self.pandasSQL.to_sql( self.test_frame1, 'test_frame1', if_exists='fail') assert self.pandasSQL.has_table('test_frame1') pytest.raises(ValueError, self.pandasSQL.to_sql, self.test_frame1, 'test_frame1', if_exists='fail') self.drop_table('test_frame1')
Example #13
Source File: test_sql.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def _to_sql_replace(self): self.drop_table('test_frame1') self.pandasSQL.to_sql( self.test_frame1, 'test_frame1', if_exists='fail') # Add to table again self.pandasSQL.to_sql( self.test_frame1, 'test_frame1', if_exists='replace') assert self.pandasSQL.has_table('test_frame1') num_entries = len(self.test_frame1) num_rows = self._count_rows('test_frame1') assert num_rows == num_entries self.drop_table('test_frame1')
Example #14
Source File: test_sql.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_to_sql(self): sql.to_sql(self.test_frame1, 'test_frame1', self.conn) assert sql.has_table('test_frame1', self.conn)
Example #15
Source File: test_sql.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_to_sql_replace(self): sql.to_sql(self.test_frame1, 'test_frame3', self.conn, if_exists='fail') # Add to table again sql.to_sql(self.test_frame1, 'test_frame3', self.conn, if_exists='replace') assert sql.has_table('test_frame3', self.conn) num_entries = len(self.test_frame1) num_rows = self._count_rows('test_frame3') assert num_rows == num_entries
Example #16
Source File: test_sql.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_to_sql_append(self): sql.to_sql(self.test_frame1, 'test_frame4', self.conn, if_exists='fail') # Add to table again sql.to_sql(self.test_frame1, 'test_frame4', self.conn, if_exists='append') assert sql.has_table('test_frame4', self.conn) num_entries = 2 * len(self.test_frame1) num_rows = self._count_rows('test_frame4') assert num_rows == num_entries
Example #17
Source File: test_sql.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_create_table(self): temp_conn = self.connect() temp_frame = DataFrame( {'one': [1., 2., 3., 4.], 'two': [4., 3., 2., 1.]}) pandasSQL = sql.SQLDatabase(temp_conn) pandasSQL.to_sql(temp_frame, 'temp_frame') assert temp_conn.has_table('temp_frame')
Example #18
Source File: test_sql.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_drop_table(self): temp_conn = self.connect() temp_frame = DataFrame( {'one': [1., 2., 3., 4.], 'two': [4., 3., 2., 1.]}) pandasSQL = sql.SQLDatabase(temp_conn) pandasSQL.to_sql(temp_frame, 'temp_frame') assert temp_conn.has_table('temp_frame') pandasSQL.drop_table('temp_frame') assert not temp_conn.has_table('temp_frame')
Example #19
Source File: test_sql.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_to_sql_fail(self): sql.to_sql(self.test_frame1, 'test_frame2', self.conn, if_exists='fail') assert sql.has_table('test_frame2', self.conn) pytest.raises(ValueError, sql.to_sql, self.test_frame1, 'test_frame2', self.conn, if_exists='fail')
Example #20
Source File: test_sql.py From twitter-stock-recommendation with MIT License | 5 votes |
def _to_sql(self): self.drop_table('test_frame1') self.pandasSQL.to_sql(self.test_frame1, 'test_frame1') assert self.pandasSQL.has_table('test_frame1') # Nuke table self.drop_table('test_frame1')
Example #21
Source File: test_sql.py From twitter-stock-recommendation with MIT License | 5 votes |
def _to_sql_fail(self): self.drop_table('test_frame1') self.pandasSQL.to_sql( self.test_frame1, 'test_frame1', if_exists='fail') assert self.pandasSQL.has_table('test_frame1') pytest.raises(ValueError, self.pandasSQL.to_sql, self.test_frame1, 'test_frame1', if_exists='fail') self.drop_table('test_frame1')
Example #22
Source File: test_sql.py From twitter-stock-recommendation with MIT License | 5 votes |
def _to_sql_replace(self): self.drop_table('test_frame1') self.pandasSQL.to_sql( self.test_frame1, 'test_frame1', if_exists='fail') # Add to table again self.pandasSQL.to_sql( self.test_frame1, 'test_frame1', if_exists='replace') assert self.pandasSQL.has_table('test_frame1') num_entries = len(self.test_frame1) num_rows = self._count_rows('test_frame1') assert num_rows == num_entries self.drop_table('test_frame1')
Example #23
Source File: test_sql.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_to_sql(self): sql.to_sql(self.test_frame1, 'test_frame1', self.conn) assert sql.has_table('test_frame1', self.conn)
Example #24
Source File: test_sql.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_to_sql_replace(self): sql.to_sql(self.test_frame1, 'test_frame3', self.conn, if_exists='fail') # Add to table again sql.to_sql(self.test_frame1, 'test_frame3', self.conn, if_exists='replace') assert sql.has_table('test_frame3', self.conn) num_entries = len(self.test_frame1) num_rows = self._count_rows('test_frame3') assert num_rows == num_entries
Example #25
Source File: test_sql.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_to_sql_append(self): sql.to_sql(self.test_frame1, 'test_frame4', self.conn, if_exists='fail') # Add to table again sql.to_sql(self.test_frame1, 'test_frame4', self.conn, if_exists='append') assert sql.has_table('test_frame4', self.conn) num_entries = 2 * len(self.test_frame1) num_rows = self._count_rows('test_frame4') assert num_rows == num_entries
Example #26
Source File: test_sql.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_create_table(self): temp_conn = self.connect() temp_frame = DataFrame( {'one': [1., 2., 3., 4.], 'two': [4., 3., 2., 1.]}) pandasSQL = sql.SQLDatabase(temp_conn) pandasSQL.to_sql(temp_frame, 'temp_frame') assert temp_conn.has_table('temp_frame')
Example #27
Source File: test_sql.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_drop_table(self): temp_conn = self.connect() temp_frame = DataFrame( {'one': [1., 2., 3., 4.], 'two': [4., 3., 2., 1.]}) pandasSQL = sql.SQLDatabase(temp_conn) pandasSQL.to_sql(temp_frame, 'temp_frame') assert temp_conn.has_table('temp_frame') pandasSQL.drop_table('temp_frame') assert not temp_conn.has_table('temp_frame')
Example #28
Source File: test_sql.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_create_and_drop_table(self): temp_frame = DataFrame( {'one': [1., 2., 3., 4.], 'two': [4., 3., 2., 1.]}) self.pandasSQL.to_sql(temp_frame, 'drop_test_frame') assert self.pandasSQL.has_table('drop_test_frame') self.pandasSQL.drop_table('drop_test_frame') assert not self.pandasSQL.has_table('drop_test_frame')
Example #29
Source File: test_sql.py From vnpy_crypto with MIT License | 5 votes |
def test_to_sql(self): sql.to_sql(self.test_frame1, 'test_frame1', self.conn) assert sql.has_table('test_frame1', self.conn)
Example #30
Source File: test_sql.py From recruit with Apache License 2.0 | 5 votes |
def _to_sql_fail(self): self.drop_table('test_frame1') self.pandasSQL.to_sql( self.test_frame1, 'test_frame1', if_exists='fail') assert self.pandasSQL.has_table('test_frame1') pytest.raises(ValueError, self.pandasSQL.to_sql, self.test_frame1, 'test_frame1', if_exists='fail') self.drop_table('test_frame1')