How to open a . sql file in pandas?

Asked

Viewed 486 times

0

I intend to make a dataframe of a database that I imported from pgadmin4 as a 'vialactea.sql' file when I try to execute the pandas command in jupyter only from the error message.

The bank is saved in the same folder as the notebook file, which facilitates access to it.

vialactea = pandas.read_sql('vialactea.sql')

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-8-376ba7310a4f> in <module>
----> 1 vialactea = pandas.read_sql('vialactea.sql')

NameError: read_sql() missing 1 required positional argument: 'con'
  • This command is for you to read from a database, so it requires the connection (required positional argument: 'con'), see the documentation

1 answer

-1

import sqlite3

conn = sqlite3.connect('teste.db')
cursor = conn.cursor()

# inserindo dados na tabela
cursor.execute("select * from banco")

Browser other questions tagged

You are not signed in. Login or sign up in order to post.