Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MetaData.__init__() got an unexpected keyword argument 'bind' when using sqlite

im very new to sqlite, im using macbook m1, im try to use jupyter notebook to do sql here is my code

%load_ext sql

import csv, sqlite3

con = sqlite3.connect("socioeconomic.db")
cur = con.cursor()

everything is okay until this but when i connect to the sqlite

%sql sqlite:///socioeconomic.db

there is error something like this

MetaData.__init__() got an unexpected keyword argument 'bind'
Connection info needed in SQLAlchemy format, example:
               postgresql://username:password@hostname/dbname
               or an existing connection: dict_keys([])

do you have any suggestion what should i do?

i tried to use other laptop but windows, and the same code works, but in mac isnt

like image 454
Rand Avatar asked Jul 01 '26 03:07

Rand


1 Answers

Essentially there are 2 ways you can connect from your Jupyter notebook to SQLite local db. I don't think it relates to your Mac version as I have M2 and it's running fine.

Check you have the .db file locally. Also, check if the same sqlalchemy versions are matching. I believe pip install sqlalchemy==1.4.4 should work. Another reason to move to Jupysql is that it supports the latest SQLAlchemy version.

Here are 2 ways you can make it run via Jupysql:

  1. You can pass your existing connections to %sql as follows:
some_engine = create_engine("sqlite:///some.db")
%sql some_engine
  1. You can connect directly to it:
%sql sqlite:///foo.db

For both options you'll need to set up the correct package and import it via %load_ext sql

like image 173
Ido Michael Avatar answered Jul 02 '26 18:07

Ido Michael



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!