Anand KC
Anand KC

Reputation: 39

Simple query working in SQL but not in Sqlite3 in python

Below is the sql query that is working fine:


SELECT * FROM contracts.wires.monthly_data

But it is not working in python


import sqlite3 
connection = sqlite3.connect("contractsdbro") 
print(connection) 
crsr = connection.cursor() 
crsr.execute("SELECT * FROM contracts.wires.monthly_data")
ans= crsr.fetchall()

Error:

 sqlite3.OperationalError: near ".": syntax error

Upvotes: 0

Views: 177

Answers (1)

Diego Torres Milano
Diego Torres Milano

Reputation: 69188

As you can see in enter image description here

the valid syntax is schema-name.table-name (you have an extra component).

You haven't provided enough information, but just guessing

crsr.execute("SELECT * FROM monthly_data") 

should work.

You can use sqlite3 command-line tool to explore your database.

Upvotes: 1

Related Questions