0

I just used the Pycharm and the package Sqlite3 to generate a table in sqlite3. Meanwhile, I am using SqliteStudio to visualize the relationship between databases and tables. However, the table created from Pycharm cannot be seen in SqliteStudio. Any idea how can I achieve it?

here is the code:

import sqlite3


def conSqlite():
  conn = sqlite3.connect('C:\\Users\jet.cai\Documents\Logsitic.db')

  conn.execute('''CREATE TABLE CNAME
  (ID INT PRIMARY KEY  NOT NULL,
  NAME            TEXT NOT NULL,
  AGE             TEXT NOT NULL)''')

  print('Done')

  cursor = conn.execute("select id from cname")
  for row in cursor:
      print('ID = ', row[0], 'NAME = ', row[1], 'AGE = ', row[2] )


  conSqlite()
2
  • You can use another app to see what is in your database (I personnally use Spatialite) Commented Oct 14, 2020 at 14:16
  • so there is no way to display the table via SQLite huh? Commented Oct 14, 2020 at 14:31

1 Answer 1

3

If you want to stay with python, you may find interesting to use pandas.

import pandas as pd
import sqlite3
con = sqlite3.connect('C:\\Users\jet.cai\Documents\Logsitic.db')
df = pd.read_sql_query("select id from cname", con)
print(df)
Sign up to request clarification or add additional context in comments.

5 Comments

Oh yes, also forgot this package, pandas will do me the favor when checking the data in Python of course, Thanks!
You're welcome. Please mark this answer as accepted if this has resolved your problem ;-)
let me check the Spatialite first, I wanna a GUI way to demonstrate what has been created, SQLite is obviously out of the way. Thanks again.
Sure, I use Spatialite for that same purpose (particularly when when I'm not sure what occured in my database...) !
Hola, sir, yes you are absolutely right, spatialite is finely able to do me the favor! Thanks again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.