Skip to content

Commit

Permalink
Merge branch 'gordthompson-sqla_2_support'
Browse files Browse the repository at this point in the history
  • Loading branch information
yehoshuadimarsky committed Nov 12, 2023
2 parents 1f8930d + 4d26629 commit 8254ba8
Show file tree
Hide file tree
Showing 5 changed files with 657 additions and 535 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ knowledge of BCP required!! (pronounced _BEE-CEE-Pandas_)
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Quickstart](#quickstart)
- [IMPORTANT - Read vs. Write](#important---read-vs-write)
- [Benchmarks](#benchmarks)
Expand Down Expand Up @@ -160,9 +161,9 @@ Azure versions.
See the
[pyodbc docs](https://github.com/mkleehammer/pyodbc/wiki/Connecting-to-SQL-Server-from-Windows)
for more on different driver versions.
- Python >= 3.7
- `pandas` >= 0.19
- `sqlalchemy` >= 1.0
- Python >= 3.8
- `pandas` >= 1.5
- `sqlalchemy` >= 1.4
- `pyodbc` as the
[supported DBAPI](https://docs.sqlalchemy.org/en/13/dialects/mssql.html#module-sqlalchemy.dialects.mssql.pyodbc)

Expand Down
25 changes: 13 additions & 12 deletions bcpandas/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,19 @@ def _create_table(
):
"""use pandas' own code to create the table and schema"""

sql_db = SQLDatabase(creds.engine, schema=schema)
table = SQLTable(
table_name,
sql_db,
frame=df,
index=False, # already set as new col earlier if index=True
if_exists=if_exists,
index_label=None,
schema=schema,
dtype=dtype,
)
table.create()
with creds.engine.begin() as conn:
sql_db = SQLDatabase(conn, schema=schema)
table = SQLTable(
table_name,
sql_db,
frame=df,
index=False, # already set as new col earlier if index=True
if_exists=if_exists,
index_label=None,
schema=schema,
dtype=dtype,
)
table.create()


def _handle_cols_for_append(
Expand Down
Loading

0 comments on commit 8254ba8

Please sign in to comment.