Click here to Skip to main content
15,499,289 members
Home / Discussions / Database
   

Database

 
QuestionHaving difficulty to replicate entries in SQL query result Pin
paul4everyone28-Jan-19 3:37
Memberpaul4everyone28-Jan-19 3:37 
AnswerRe: Having difficulty to replicate entries in SQL query result Pin
Richard MacCutchan28-Jan-19 3:56
mveRichard MacCutchan28-Jan-19 3:56 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
paul4everyone28-Jan-19 5:20
Memberpaul4everyone28-Jan-19 5:20 
SuggestionRe: Having difficulty to replicate entries in SQL query result Pin
ZurdoDev28-Jan-19 5:48
professionalZurdoDev28-Jan-19 5:48 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
paul4everyone28-Jan-19 7:54
Memberpaul4everyone28-Jan-19 7:54 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
Richard MacCutchan28-Jan-19 7:01
mveRichard MacCutchan28-Jan-19 7:01 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
paul4everyone28-Jan-19 7:51
Memberpaul4everyone28-Jan-19 7:51 
AnswerRe: Having difficulty to replicate entries in SQL query result Pin
Mycroft Holmes28-Jan-19 12:02
professionalMycroft Holmes28-Jan-19 12:02 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
paul4everyone28-Jan-19 16:02
Memberpaul4everyone28-Jan-19 16:02 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
Mycroft Holmes29-Jan-19 11:58
professionalMycroft Holmes29-Jan-19 11:58 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
paul4everyone31-Jan-19 11:50
Memberpaul4everyone31-Jan-19 11:50 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
Mycroft Holmes31-Jan-19 12:15
professionalMycroft Holmes31-Jan-19 12:15 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
paul4everyone2-Feb-19 20:03
Memberpaul4everyone2-Feb-19 20:03 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
Mycroft Holmes2-Feb-19 20:29
professionalMycroft Holmes2-Feb-19 20:29 
Questionis it safe to use this with sql server and entity framework ? Pin
desanti9-Jan-19 15:38
Memberdesanti9-Jan-19 15:38 
AnswerRe: is it safe to use this with sql server and entity framework ? Pin
Mycroft Holmes9-Jan-19 20:51
professionalMycroft Holmes9-Jan-19 20:51 
AnswerRe: is it safe to use this with sql server and entity framework ? Pin
Eddy Vluggen10-Jan-19 3:17
professionalEddy Vluggen10-Jan-19 3:17 
QuestionGetting error in SQL 2012 working fine in 2016 Pin
GaneshVidiyala25-Dec-18 22:41
professionalGaneshVidiyala25-Dec-18 22:41 
AnswerRe: Getting error in SQL 2012 working fine in 2016 Pin
jschell27-Dec-18 14:34
Memberjschell27-Dec-18 14:34 
Questionssrs An attempt has been made to use a data extension 'ORACLE' error Pin
anjel8425-Dec-18 21:34
Memberanjel8425-Dec-18 21:34 
AnswerRe: ssrs An attempt has been made to use a data extension 'ORACLE' error Pin
rnbergren24-Jan-19 9:24
Memberrnbergren24-Jan-19 9:24 
QuestionCan't Insert data into Access Table from Python - Solved Pin
Peter R. Fletcher5-Dec-18 16:16
MemberPeter R. Fletcher5-Dec-18 16:16 
The following short Python program is supposed to read data from a SQLite datatable, convert some very large integer values in one field to Doubles, and write the data to an appropriately configured Access Table.
It runs happily with no error, but no data appears in the Access Table. What am I missing?
Python
import sqlite3
import pyodbc

conn1 = sqlite3.connect('data.db')
cur1 = conn1.cursor()

conn2 = pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=G:\My_Data_Folder\NewEnergy.accdb;')
cur2 = conn2.cursor()

data=cur2.execute('SELECT * FROM RawValues')
print (cur2.fetchall()) # this correctly displays two dummy records from the Table I am trying to fill

data=cur1.execute('SELECT * FROM RTPValues ORDER BY TimeSerial ASC')
rows=cur1.fetchall()
for row in rows:
    cur2.execute('INSERT INTO RawValues (Millitime, PowerCost) VALUES (?,?)',(float(row[0]),row[1]))
    # If I insert print statements here, they confirm that the right data is being processed
conn2.commit
conn2.close
conn1.close


[EDIT]The error, as pointed out by Richard MacCutchan at the end of the thread, is that the conn2.commit call (as well as the subsequent .close calls) are not function calls at all, because they are missing the terminal empty parentheses that are required for Python to treat them as such. The last three lines of the code should be:
Python
conn2.commit()
conn2.close()
conn1.close()
As it stands, the program does what it is supposed to do, but the data is never written to the file.[/EDIT]

modified 8-Dec-18 14:51pm.

AnswerRe: Can't Insert data into Access Table from Python Pin
Richard MacCutchan5-Dec-18 23:19
mveRichard MacCutchan5-Dec-18 23:19 
GeneralRe: Can't Insert data into Access Table from Python Pin
Victor Nijegorodov6-Dec-18 2:09
MemberVictor Nijegorodov6-Dec-18 2:09 
GeneralRe: Can't Insert data into Access Table from Python Pin
Richard MacCutchan6-Dec-18 2:21
mveRichard MacCutchan6-Dec-18 2:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.